Generate the given object.

@param tryStatement the try-catch-finally statement.
@param it the target for the generated content.
@param context the context.
@return the statement.
422463
protected XExpression _generate(XTryCatchFinallyExpression tryStatement, IAppendable it, IExtraLanguageGeneratorContext context) {
		it.append("try:"); //$NON-NLS-1$
		it.increaseIndentation().newLine();
		generate(tryStatement.getExpression(), context.getExpectedExpressionType(), it, context);
		it.decreaseIndentation().newLine();
		for (final XCatchClause clause : tryStatement.getCatchClauses()) {
			it.append("except "); //$NON-NLS-1$
			it.append(clause.getDeclaredParam().getParameterType().getType());
			it.append(", "); //$NON-NLS-1$
			it.append(it.declareUniqueNameVariable(clause.getDeclaredParam(), clause.getDeclaredParam().getSimpleName()));
			it.append(":"); //$NON-NLS-1$
			it.increaseIndentation().newLine();
			generate(clause.getExpression(), context.getExpectedExpressionType(), it, context);
			it.decreaseIndentation().newLine();
		}
		if (tryStatement.getFinallyExpression() != null) {
			it.append("finally:"); //$NON-NLS-1$
			it.increaseIndentation().newLine();
			generate(tryStatement.getFinallyExpression(), it, context);
			it.decreaseIndentation();
		}
		return tryStatement;
	}
1326523
private void doExecute(Connection conn) throws SQLException
    {
        PreparedStatement stmt;
        int size;

        size = _methods.size();
        if ( size == 0 )
        {
            return;
        }
        stmt = conn.prepareStatement(_sql);
        try
        {
            m_platform.afterStatementCreate(stmt);
        }
        catch ( PlatformException e )
        {
            if ( e.getCause() instanceof SQLException )
            {
                throw (SQLException)e.getCause();
            }
            else
            {
                throw new SQLException(e.getMessage());
            }
        }
        try
        {
            m_platform.beforeBatch(stmt);
        }
        catch ( PlatformException e )
        {
            if ( e.getCause() instanceof SQLException )
            {
                throw (SQLException)e.getCause();
            }
            else
            {
                throw new SQLException(e.getMessage());
            }
        }
        try
        {
            for ( int i = 0; i < size; i++ )
            {
                Method method = (Method) _methods.get(i);
                try
                {
                    if ( method.equals(ADD_BATCH) )
                    {
                        /**
                         * we invoke on the platform and pass the stmt as an arg.
                         */
                        m_platform.addBatch(stmt);
                    }
                    else
                    {
                        method.invoke(stmt, (Object[]) _params.get(i));
                    }
                }
                catch (IllegalArgumentException ex)
                {
					StringBuffer buffer = generateExceptionMessage(i, stmt, ex);
					throw new SQLException(buffer.toString());
                }
                catch ( IllegalAccessException ex )
                {
					StringBuffer buffer = generateExceptionMessage(i, stmt, ex);
                    throw new SQLException(buffer.toString());
                }
                catch ( InvocationTargetException ex )
                {
                    Throwable th = ex.getTargetException();

                    if ( th == null )
                    {
                        th = ex;
                    }
                    if ( th instanceof SQLException )
                    {
                        throw ((SQLException) th);
                    }
                    else
                    {
                        throw new SQLException(th.toString());
                    }
                }
				catch (PlatformException e)
				{
					throw new SQLException(e.toString());
				}
            }
            try
            {
                /**
                 * this will call the platform specific call
                 */
                m_platform.executeBatch(stmt);
            }
            catch ( PlatformException e )
            {
                if ( e.getCause() instanceof SQLException )
                {
                    throw (SQLException)e.getCause();
                }
                else
                {
                    throw new SQLException(e.getMessage());
                }
            }

        }
        finally
        {
            stmt.close();
            _methods.clear();
            _params.clear();
        }
    }
269244
protected void _generate(SarlClass clazz, PyAppendable it, IExtraLanguageGeneratorContext context) {
		generateTypeDeclaration(
				this.qualifiedNameProvider.getFullyQualifiedName(clazz).toString(),
				clazz.getName(), clazz.isAbstract(),
				getSuperTypes(clazz.getExtends(), clazz.getImplements()),
				getTypeBuilder().getDocumentation(clazz),
				true,
				clazz.getMembers(), it, context, null);
	}
251988
private final TryCatchFinally tryStatement(Data data) throws TemplateException {
	if (!data.srcCode.forwardIfCurrent("try", '{') && !data.srcCode.forwardIfCurrent("try ") && !data.srcCode.forwardIfCurrent("try", '/')) return null;
	data.srcCode.previous();

	Body body = new BodyBase(data.factory);
	TryCatchFinally tryCatchFinally = new TryCatchFinally(data.factory, body, data.srcCode.getPosition(), null);

	Body prior = data.setParent(body);
	statement(data, body, CTX_TRY);
	data.setParent(prior);
	comments(data);

	// catches
	short catchCount = 0;
	while (data.srcCode.forwardIfCurrent("catch", '(')) {
	    catchCount++;
	    comments(data);

	    // type
	    int pos = data.srcCode.getPos();
	    Position line = data.srcCode.getPosition();
	    Expression name = null, type = null;

	    StringBuffer sbType = new StringBuffer();
	    String id;
	    while (true) {
		id = identifier(data, false);
		if (id == null) break;
		sbType.append(id);
		data.srcCode.removeSpace();
		if (!data.srcCode.forwardIfCurrent('.')) break;
		sbType.append('.');
		data.srcCode.removeSpace();
	    }

	    if (sbType.length() == 0) {
		type = string(data);
		if (type == null) throw new TemplateException(data.srcCode, "a catch statement must begin with the throwing type (query, application ...).");
	    }
	    else {
		type = data.factory.createLitString(sbType.toString());
	    }

	    // name = expression();
	    comments(data);

	    // name
	    if (!data.srcCode.isCurrent(')')) {
		name = expression(data);
	    }
	    else {
		data.srcCode.setPos(pos);
		name = expression(data);
		type = data.factory.createLitString("any");
	    }
	    comments(data);

	    Body b = new BodyBase(data.factory);
	    try {
		tryCatchFinally.addCatch(type, name, b, line);
	    }
	    catch (TransformerException e) {
		throw new TemplateException(data.srcCode, e.getMessage());
	    }
	    comments(data);

	    if (!data.srcCode.forwardIfCurrent(')')) throw new TemplateException(data.srcCode, "invalid catch statement, missing closing )");

	    Body _prior = data.setParent(b);
	    statement(data, b, CTX_CATCH);
	    data.setParent(_prior);
	    comments(data);
	}

	// finally
	if (finallyStatement(data, tryCatchFinally)) {
	    comments(data);
	}
	else if (catchCount == 0) throw new TemplateException(data.srcCode, "a try statement must have at least one catch statement");

	// if(body.isEmpty()) return null;
	tryCatchFinally.setEnd(data.srcCode.getPosition());
	return tryCatchFinally;
    }
838543
@Override
  public OperationHandle executeStatement(SessionHandle sessionHandle, String statement,
      Map<String, String> confOverlay)
          throws HiveSQLException {
    return executeStatementInternal(sessionHandle, statement, confOverlay, false);
  }
1018019
private void executeStatement(String statement) throws SQLException {

        Statement stmt = null;

        try {
            stmt = m_con.createStatement();
            stmt.execute(statement);
        } finally {
            if (stmt != null) {
                stmt.close();
            }
        }
    }
816600
protected void _generate(SarlField field, PyAppendable it, IExtraLanguageGeneratorContext context) {
		if (field.isStatic()) {
			// Static field
			generatePythonField(field, it, context);
		} else {
			final String key = this.qualifiedNameProvider.getFullyQualifiedName(field.getDeclaringType()).toString();
			final List<SarlField> fields = context.getMultimapValues(INSTANCE_VARIABLES_MEMENTO, key);
			fields.add(field);
		}
	}
816137
public void setStatement(Statement statement, int iType)
    {
        try {
            if (this.getStatement(iType) != null)
                this.getStatement(iType).close();
            if (statement == null)
                this.setLastSQLStatement(null, iType);
        } catch (SQLException e) {
            e.printStackTrace();    // Never
        }

        switch (iType)
        {
        case DBConstants.SQL_UPDATE_TYPE:
        case DBConstants.SQL_INSERT_TABLE_TYPE:
        case DBConstants.SQL_DELETE_TYPE:
            m_updateStatement = statement;
            break;
        case DBConstants.SQL_AUTOSEQUENCE_TYPE:
        case DBConstants.SQL_SEEK_TYPE:
            if (!SHARE_STATEMENTS)
            {
                m_seekStatement = statement;
                break;
            }
        case DBConstants.SQL_SELECT_TYPE:
        case DBConstants.SQL_CREATE_TYPE:
        default:
            m_queryStatement = statement;
        }
    }
815016
protected XExpression _generate(XThrowExpression throwStatement, IAppendable it, IExtraLanguageGeneratorContext context) {
		it.append("raise "); //$NON-NLS-1$
		generate(throwStatement.getExpression(), it, context);
		return throwStatement;
	}
1324793
protected XExpression _generate(XBasicForLoopExpression forLoop, IAppendable it, IExtraLanguageGeneratorContext context) {
		for (final XExpression expr : forLoop.getInitExpressions()) {
			generate(expr, it, context);
			it.newLine();
		}
		it.append("while "); //$NON-NLS-1$
		generate(forLoop.getExpression(), it, context);
		it.append(":"); //$NON-NLS-1$
		it.increaseIndentation().newLine();
		final XExpression last = generate(forLoop.getEachExpression(), it, context);
		for (final XExpression expr : forLoop.getUpdateExpressions()) {
			it.newLine();
			generate(expr, it, context);
		}
		it.decreaseIndentation();
		return last;
	}
249851
static ResultSet executeStatement(SQL sql) throws SQLException {
    try (SqlSession session = sqlSessionFactory.openSession(true)) {
      try (Connection conn = session.getConnection()) {
        try (Statement stmt = conn.createStatement()) {
          return stmt.executeQuery(sql.toString());
        }
      }
    }
  }
25020
private final Statement ifStatement(Data data) throws TemplateException {
	if (!data.srcCode.forwardIfCurrent("if", '(')) return null;

	Position line = data.srcCode.getPosition();

	Body body = new BodyBase(data.factory);
	Condition cont = new Condition(data.factory, condition(data), body, line, null);

	if (!data.srcCode.forwardIfCurrent(')')) throw new TemplateException(data.srcCode, "if statement must end with a [)]");
	// ex block
	Body prior = data.setParent(body);
	statement(data, body, CTX_IF);
	data.setParent(prior);
	// else if
	comments(data);
	while (elseifStatement(data, cont)) {
	    comments(data);
	}
	// else
	if (elseStatement(data, cont)) {
	    comments(data);
	}

	cont.setEnd(data.srcCode.getPosition());
	return cont;
    }
853892
static int execSql(SQLiteDatabase db, String label, String finalSql, Object[] argArray) throws SQLException {
		try {
			db.execSQL(finalSql, argArray);
		} catch (android.database.SQLException e) {
			throw SqlExceptionUtil.create("Problems executing " + label + " Android statement: " + finalSql, e);
		}
		int result;
		SQLiteStatement stmt = null;
		try {
			// ask sqlite how many rows were just changed
			stmt = db.compileStatement("SELECT CHANGES()");
			result = (int) stmt.simpleQueryForLong();
		} catch (android.database.SQLException e) {
			// ignore the exception and just return 1 if it failed
			result = 1;
		} finally {
			if (stmt != null) {
				stmt.close();
			}
		}
		logger.trace("executing statement {} changed {} rows: {}", label, result, finalSql);
		return result;
	}
1353545
protected final void usePreparedStatement( PreparedStatement pPreparedStatement ) throws SQLException
  {
    ResultSet lResultSet = null;
    
    pPreparedStatement.setFetchSize( 1000 );

    setParameter( pPreparedStatement );

    try
    {
      lResultSet = pPreparedStatement.executeQuery();

      useResultSet( lResultSet );
    }
    finally
    {
      if( lResultSet != null )
      {
        lResultSet.close();
      }
    }
  }
355797
@SuppressWarnings("static-method")
	protected XExpression _generate(SarlBreakExpression breakStatement, IAppendable it, IExtraLanguageGeneratorContext context) {
		if (context.getExpectedExpressionType() == null) {
			it.append("break"); //$NON-NLS-1$
		} else {
			it.append("return ").append(toDefaultValue(context.getExpectedExpressionType().toJavaCompliantTypeReference())); //$NON-NLS-1$
		}
		return breakStatement;
	}
174659
@Override
	public PreparedStatement doPreparedStatement(final SqlContext sqlContext, final PreparedStatement preparedStatement)
			throws SQLException {
		if (getFilters().isEmpty()) {
			return preparedStatement;
		}
		PreparedStatement ps = preparedStatement;
		for (final SqlFilter filter : getFilters()) {
			ps = filter.doPreparedStatement(sqlContext, ps);
		}
		return ps;
	}
1361190
PreparedStatement getPreparedStatement(final SqlContext sqlContext) throws SQLException {
		Connection conn = null;
		if (sqlContext.getDbAlias() != null) {
			conn = getConnection(sqlContext.getDbAlias());
		} else {
			conn = getConnection();
		}

		if (conn == null) {
			throw new IllegalArgumentException(sqlContext.getDbAlias());
		}

		PreparedStatement stmt = null;
		switch (sqlContext.getSqlKind()) {
		case INSERT:
		case BULK_INSERT:
		case BATCH_INSERT:
			if (sqlContext.hasGeneratedKeyColumns()) {
				stmt = conn.prepareStatement(sqlContext.getExecutableSql(), sqlContext.getGeneratedKeyColumns());
			} else {
				stmt = conn.prepareStatement(sqlContext.getExecutableSql(), Statement.RETURN_GENERATED_KEYS);
			}
			break;
		case SELECT:
			stmt = conn.prepareStatement(sqlContext.getExecutableSql(),
					sqlContext.getResultSetType(),
					sqlContext.getResultSetConcurrency());
			break;
		default:
			stmt = conn.prepareStatement(sqlContext.getExecutableSql());
			break;
		}
		return sqlFilterManager.doPreparedStatement(sqlContext, stmt);
	}