Esempio n. 1
0
 /**
  * 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);
   }
 }
Esempio n. 2
0
 /**
  * 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;
   }
 }
Esempio n. 4
0
 @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);
     }
   }
 }
Esempio n. 5
0
  @Override
  public void closeStatement() throws Exception {
    if (statement != null && !statement.isClosed()) {
      try {
        statement.cancel();
      } catch (Exception e) {

      }
      try {
        statement.close();
      } catch (Exception e) {

      }
    }
  }
Esempio n. 6
0
 @Override
 public void cancel() throws SQLException {
   stat.cancel();
 }
Esempio n. 7
0
 public void cancel() throws SQLException {
   pst.cancel();
 };
 @Override
 public void cancel() throws SQLException {
   inner.cancel();
 }
 @Override
 public void cancel() throws SQLException {
   rawStatement.cancel();
 }