@Override public void execute(final Statement statement) throws SQLException { statement.cancel(); } });
@Override public void cancel() throws SQLException { targetStatement.cancel(); }
@Override public void cancel() throws SQLException { statement.cancel(); }
@Override public void cancel() throws SQLException { delegate.cancel(); }
public void cancel() throws SQLException { stmt.cancel(); }
/** * Close the connection and stop the statement if one is currently * executing. */ void close() { if (executingStatement != null) { try { executingStatement.cancel(); } catch (Exception e) { // ignore } } if (conn != null) { try { conn.close(); } catch (Exception e) { // ignore } } }
@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 cancelLastQuery() { try { if (lastQuery != null) { lastQuery.cancel(); } } catch (SQLException sqle) { throw exceptionHelper.convert( sqle, "Cannot cancel query" ); } finally { lastQuery = null; } }
@Override public final void cancel() throws SQLException { checkOpen(); try { stmt.cancel(); } catch (Throwable t) { throw checkException(t); } }
@Override public void statement_cancel(StatementProxy statement) throws SQLException { if (this.pos < filterSize) { nextFilter().statement_cancel(this, statement); return; } statement.getRawObject().cancel(); }
@Override public void handle (Signal signal) { try { // exit the JVM if Ctrl+C is received // and no current statement is executing if(stmt == null || stmt.isClosed()) { System.exit(127); } else { beeLine.info(beeLine.loc("interrupt-ctrl-c")); stmt.cancel(); } } catch (SQLException ex) { // ignore } } }
/** * Ensure that it's possible to execute new query on cancelled statement. * * @throws Exception If failed. */ @Test public void testCancelAnotherStmt() throws Exception { stmt.setFetchSize(10); ResultSet rs = stmt.executeQuery("select * from Integer"); assert rs.next(); stmt.cancel(); ResultSet rs2 = stmt.executeQuery("select * from Integer order by _val"); assert rs2.next() : "The other cursor mustn't be closed"; }
/** * Cancel an open/running SQL statement * * @param statement the statement to cancel * @throws KettleDatabaseException */ public void cancelStatement( Statement statement ) throws KettleDatabaseException { try { if ( statement != null ) { statement.cancel(); } if ( log.isDebug() ) { log.logDebug( "Statement canceled!" ); } } catch ( SQLException ex ) { throw new KettleDatabaseException( "Error cancelling statement", ex ); } }
/** * Trying to cancel already cancelled query. * No exceptions exceped. * * @throws Exception If failed. */ @Test public void testCancelCanceledQuery() throws Exception { stmt.execute("SELECT 1;"); assertNotNull(stmt.getResultSet()); stmt.cancel(); stmt.cancel(); GridTestUtils.assertThrows(log, () -> { stmt.getResultSet(); return null; }, SQLException.class, "The query was cancelled while executing."); }
/** * Trying to call <code>resultSet.next()</code> on a canceled query. * SQLException with message "The query was cancelled while executing." expected. * * @throws Exception If failed. */ @Test public void testResultSetNextAfterCanceling() throws Exception { stmt.setFetchSize(10); ResultSet rs = stmt.executeQuery("select * from Integer"); assert rs.next(); stmt.cancel(); GridTestUtils.assertThrows(log, () -> { rs.next(); return null; }, SQLException.class, "The query was cancelled while executing."); }
statement.cancel();
statement.cancel();
/** * Trying to cancel closed query. * SQLException with message "Statement is closed." expected. * * @throws Exception If failed. */ @Test public void testCancelClosedStmt() throws Exception { stmt.close(); GridTestUtils.assertThrows(log, () -> { stmt.cancel(); return null; }, SQLException.class, "Statement is closed."); }
/** * Trying to retrieve result set of a canceled query. * SQLException with message "The query was cancelled while executing." expected. * * @throws Exception If failed. */ @Test public void testResultSetRetrievalInCanceledStatement() throws Exception { stmt.execute("SELECT 1; SELECT 2; SELECT 3;"); assertNotNull(stmt.getResultSet()); stmt.cancel(); GridTestUtils.assertThrows(log, () -> { stmt.getResultSet(); return null; }, SQLException.class, "The query was cancelled while executing."); }
/** * Trying to cancel stament without query. In given case cancel is noop, so no exception expected. */ @Test public void testCancelingStmtWithoutQuery() { try { stmt.cancel(); } catch (Exception e) { log.error("Unexpected exception.", e); fail("Unexpected exception"); } }