@Override public boolean isClosed() throws SQLException { return rawStatement.isClosed(); }
@Override public boolean isClosed() throws SQLException { return rawStatement.isClosed(); }
/** {@inheritDoc} */ @Override public boolean isClosed() throws SQLException { return delegate.isClosed(); }
public PreparedStatement get(String sql) throws SQLException { synchronized (elements) { if (closed) { return null; } PreparedStatement statement = elements.remove(sql); if (statement != null && statement.isClosed()) { return null; } return statement; } }
@Override public void close() { try { if (null != statement && !statement.isClosed()) { statement.close(); } } catch (SQLException ex) { logger.warn("Error closing prepared statement: {}", ex.getMessage()); } }
public void cancel() { try { if (statement != null && !statement.isClosed()) { statement.cancel(); connection.rollback(); } } catch (SQLException e) { //do nothing } }
private void closeStatement(PreparedStatement statement) { try { if (!statement.isClosed()) { if (statement instanceof CachedStatement) { CachedStatement delegate = (CachedStatement) statement; delegate.closeDelegate(); } } } catch (SQLException ignored) { ignored.printStackTrace(); } } }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { if (stmt != null) { stmt.close(); assert stmt.isClosed(); } if (conn != null) { conn.close(); assert conn.isClosed(); } }
protected void clearBatch(PreparedStatement statement) { try { // This code can be called after the connection is released // and the statement is closed. If the statement is closed, // then SQLException will be thrown when PreparedStatement#clearBatch // is called. // Ensure the statement is not closed before // calling PreparedStatement#clearBatch. if ( !statement.isClosed() ) { statement.clearBatch(); } } catch ( SQLException e ) { LOG.unableToReleaseBatchStatement(); } }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { if (stmt != null) { stmt.close(); assert stmt.isClosed(); } if (conn != null) { conn.close(); assert conn.isClosed(); } }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { if (stmt != null) { stmt.close(); assert stmt.isClosed(); } if (conn != null) { conn.close(); assert conn.isClosed(); } }
@Override public void cleanup() throws DBException { if (batchSize > 0) { try { // commit un-finished batches for (PreparedStatement st : cachedStatements.values()) { if (!st.getConnection().isClosed() && !st.isClosed() && (numRowsInBatch % batchSize != 0)) { st.executeBatch(); } } } catch (SQLException e) { System.err.println("Error in cleanup execution. " + e); throw new DBException(e); } } try { cleanupAllConnections(); } catch (SQLException e) { System.err.println("Error in closing the connection. " + e); throw new DBException(e); } }
@Test public void testClosedPreparedStatement_isClosed_returnsTrue() throws SQLException { assertThat(closedPreparedStmtOfOpenConn.isClosed(), equalTo(true)); }
/** * Get cached prepared statement (if any). * * @param c Connection. * @param sql SQL. * @return Prepared statement or {@code null}. * @throws SQLException On error. */ @Nullable public PreparedStatement cachedPreparedStatement(Connection c, String sql) throws SQLException { H2StatementCache cache = statementCacheForThread(); H2CachedStatementKey key = new H2CachedStatementKey(c.getSchema(), sql); PreparedStatement stmt = cache.get(key); if (stmt != null && !stmt.isClosed() && !stmt.unwrap(JdbcStatement.class).isCancelled() && !GridSqlQueryParser.prepared(stmt).needRecompile()) { assert stmt.getConnection() == c; return stmt; } return null; }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); stmt = conn.createStatement(); prepStmt = conn.prepareStatement(SQL_PREPARED); assertNotNull(stmt); assertFalse(stmt.isClosed()); assertNotNull(prepStmt); assertFalse(prepStmt.isClosed()); int paramCnt = 1; for (Object[] arg : args) { prepStmt.setString(paramCnt++, (String)arg[0]); prepStmt.setInt(paramCnt++, (Integer)arg[1]); prepStmt.setString(paramCnt++, (String)arg[2]); prepStmt.setString(paramCnt++, (String)arg[3]); prepStmt.setInt(paramCnt++, (Integer)arg[4]); } }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); stmt = conn.createStatement(); prepStmt = conn.prepareStatement(SQL_PREPARED); assertNotNull(stmt); assertFalse(stmt.isClosed()); assertNotNull(prepStmt); assertFalse(prepStmt.isClosed()); }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); stmt = conn.createStatement(); pstmt = conn.prepareStatement(SQL_PREPARED); assertNotNull(stmt); assertFalse(stmt.isClosed()); assertNotNull(pstmt); assertFalse(pstmt.isClosed()); }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); stmt = conn.createStatement(); prepStmt = conn.prepareStatement(SQL_PREPARED); assertNotNull(stmt); assertFalse(stmt.isClosed()); assertNotNull(prepStmt); assertFalse(prepStmt.isClosed()); }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); stmt = conn.createStatement(); prepStmt = conn.prepareStatement(SQL_PREPARED); assertNotNull(stmt); assertFalse(stmt.isClosed()); assertNotNull(prepStmt); assertFalse(prepStmt.isClosed()); }