/** * Closes this connection. All open statements, prepared statements and result sets that where * created by this connection become invalid after calling this method. If there is an uncommitted * transaction, it will be rolled back. */ public synchronized void close() throws SQLException { try { debugCodeCall("close"); openStackTrace = null; if (executingStatement != null) { executingStatement.cancel(); } if (session == null) { return; } session.cancel(); try { synchronized (session) { if (!session.isClosed()) { try { // roll back unless that would require to re-connect // (the transaction can't be rolled back after re-connecting) if (!session.isReconnectNeeded(true)) { rollbackInternal(); session.afterWriting(); } closePreparedCommands(); } finally { session.close(); } } } } finally { session = null; } } catch (Exception e) { throw logAndConvert(e); } }
/** * Ensure the cancel call does not return before it has completed. Previously it did which * cancelled future queries. */ public void testSingleThreadCancel() throws Exception { Connection con = TestUtil.openDB(); Statement stmt = con.createStatement(); for (int i = 0; i < 100; i++) { ResultSet rs = stmt.executeQuery("SELECT 1"); rs.close(); stmt.cancel(); } TestUtil.closeDB(con); }
@Override public void cancelLastQuery() { try { if (lastQuery != null) { lastQuery.cancel(); } } catch (SQLException e) { throw convert(e, "Cannot cancel query"); } finally { lastQuery = null; } }
@Override public void run() { while (!stop) { try { Thread.sleep(wait); cancel.cancel(); Thread.yield(); } catch (SQLException e) { // ignore errors on closed statements } catch (Exception e) { TestBase.logError("sleep", e); } } }
@Override public void closeStatement() throws Exception { if (statement != null && !statement.isClosed()) { try { statement.cancel(); } catch (Exception e) { } try { statement.close(); } catch (Exception e) { } } }
@Override public void cancel() throws SQLException { stat.cancel(); }
public void cancel() throws SQLException { pst.cancel(); };
@Override public void cancel() throws SQLException { inner.cancel(); }
@Override public void cancel() throws SQLException { rawStatement.cancel(); }