/** * Allocate a statement for dynamic SQL execution. * Either return the cached dynamic statement, or a new statement. * This statement must be released after execution. */ public synchronized Statement allocateDynamicStatement(Connection connection) throws SQLException { if (dynamicStatement == null) { dynamicStatement = connection.createStatement(); } if (isDynamicStatementInUse()) { return connection.createStatement(); } setIsDynamicStatementInUse(true); return dynamicStatement; }
/** * Allocate a statement for dynamic SQL execution. * Either return the cached dynamic statement, or a new statement. * This statement must be released after execution. */ public synchronized Statement allocateDynamicStatement(Connection connection) throws SQLException { if (dynamicStatement == null) { dynamicStatement = connection.createStatement(); } if (isDynamicStatementInUse()) { return connection.createStatement(); } setIsDynamicStatementInUse(true); return dynamicStatement; }
/** * Allocate a statement for dynamic SQL execution. * Either return the cached dynamic statement, or a new statement. * This statement must be released after execution. */ public synchronized Statement allocateDynamicStatement(Connection connection) throws SQLException { if (dynamicStatement == null) { dynamicStatement = connection.createStatement(); } if (isDynamicStatementInUse()) { return connection.createStatement(); } setIsDynamicStatementInUse(true); return dynamicStatement; }
/** * Flush the statement cache. * Each statement must first be closed. */ public void clearStatementCache(AbstractSession session) { if (hasStatementCache()) { for (Statement statement : getStatementCache().values()) { try { statement.close(); } catch (SQLException exception) { // an exception can be raised if // a statement is closed twice. } } this.statementCache = null; } // Close cached dynamic statement. if (this.dynamicStatement != null) { try { this.dynamicStatement.close(); } catch (SQLException exception) { // an exception can be raised if // a statement is closed twice. } this.dynamicStatement = null; this.setIsDynamicStatementInUse(false); } }
/** * Flush the statement cache. * Each statement must first be closed. */ public void clearStatementCache(AbstractSession session) { if (hasStatementCache()) { for (Statement statement : getStatementCache().values()) { try { statement.close(); } catch (SQLException exception) { // an exception can be raised if // a statement is closed twice. } } this.statementCache = null; } // Close cached dynamic statement. if (this.dynamicStatement != null) { try { this.dynamicStatement.close(); } catch (SQLException exception) { // an exception can be raised if // a statement is closed twice. } this.dynamicStatement = null; this.setIsDynamicStatementInUse(false); } }
/** * Flush the statement cache. * Each statement must first be closed. */ public void clearStatementCache(AbstractSession session) { if (hasStatementCache()) { for (Statement statement : getStatementCache().values()) { try { statement.close(); } catch (SQLException exception) { // an exception can be raised if // a statement is closed twice. } } this.statementCache = null; } // Close cached dynamic statement. if (this.dynamicStatement != null) { try { this.dynamicStatement.close(); } catch (SQLException exception) { // an exception can be raised if // a statement is closed twice. } this.dynamicStatement = null; this.setIsDynamicStatementInUse(false); } }
/** * INTERNAL: * Closes a PreparedStatement (which is supposed to close it's current resultSet). * Factored out to simplify coding and handle exceptions. */ public void closeStatement(Statement statement, AbstractSession session, DatabaseCall call) throws SQLException { if (statement == null) { decrementCallCount(); return; } DatabaseQuery query = ((call == null)? null : call.getQuery()); try { session.startOperationProfile(SessionProfiler.StatementExecute, query, SessionProfiler.ALL); statement.close(); } finally { session.endOperationProfile(SessionProfiler.StatementExecute, query, SessionProfiler.ALL); decrementCallCount(); // If this is the cached dynamic statement, release it. if (statement == this.dynamicStatement) { this.dynamicStatement = null; // The dynamic statement is cached and only closed on disconnect. setIsDynamicStatementInUse(false); } } }
/** * INTERNAL: * Closes a PreparedStatement (which is supposed to close it's current resultSet). * Factored out to simplify coding and handle exceptions. */ public void closeStatement(Statement statement, AbstractSession session, DatabaseCall call) throws SQLException { if (statement == null) { decrementCallCount(); return; } DatabaseQuery query = ((call == null)? null : call.getQuery()); try { session.startOperationProfile(SessionProfiler.STATEMENT_EXECUTE, query, SessionProfiler.ALL); statement.close(); } finally { session.endOperationProfile(SessionProfiler.STATEMENT_EXECUTE, query, SessionProfiler.ALL); decrementCallCount(); // If this is the cached dynamic statement, release it. if (statement == this.dynamicStatement) { this.dynamicStatement = null; // The dynamic statement is cached and only closed on disconnect. setIsDynamicStatementInUse(false); } } }
setIsDynamicStatementInUse(false); decrementCallCount(); } else {
/** * INTERNAL: * Closes a PreparedStatement (which is supposed to close it's current resultSet). * Factored out to simplify coding and handle exceptions. */ public void closeStatement(Statement statement, AbstractSession session, DatabaseCall call) throws SQLException { if (statement == null) { decrementCallCount(); return; } DatabaseQuery query = ((call == null)? null : call.getQuery()); try { session.startOperationProfile(SessionProfiler.StatementExecute, query, SessionProfiler.ALL); statement.close(); } finally { session.endOperationProfile(SessionProfiler.StatementExecute, query, SessionProfiler.ALL); decrementCallCount(); // If this is the cached dynamic statement, release it. if (statement == this.dynamicStatement) { this.dynamicStatement = null; // The dynamic statement is cached and only closed on disconnect. setIsDynamicStatementInUse(false); } } }
resetStatementFromCall(statement, call); setIsDynamicStatementInUse(false); decrementCallCount(); } else {
resetStatementFromCall(statement, call); setIsDynamicStatementInUse(false); decrementCallCount(); } else {