Esempio n. 1
0
 @Override
 public <T> DbSessionFuture<T> executeQuery(
     String sql, ResultHandler<T> eventHandler, T accumulator) {
   checkClosed();
   return (DbSessionFuture)
       queRequest(MySqlRequests.executeQuery(sql, eventHandler, accumulator, this)).getFuture();
 }
Esempio n. 2
0
 @Override
 public void beginTransaction() {
   if (isInTransaction()) {
     throw new DbException("This connection is already in a transaction");
   }
   checkClosed();
   synchronized (lock) {
     forceQueRequest(MySqlRequests.beginTransaction(this));
     isInTransaction = true;
   }
 }
Esempio n. 3
0
 @Override
 public DbSessionFuture<Void> rollback() {
   if (!isInTransaction()) {
     throw new DbException("No transaction has been started to rollback");
   }
   checkClosed();
   synchronized (lock) {
     final MySqlRequest request = queRequest(MySqlRequests.rollbackTransaction(this));
     isInTransaction = false;
     return (DbSessionFuture<Void>) request.getFuture();
   }
 }
Esempio n. 4
0
 @Override
 public DbFuture<Void> close(CloseMode closeMode) throws DbException {
   synchronized (lock) {
     if (null == closeFuture) {
       final MySqlRequest closeRequest = MySqlRequests.createCloseRequest(this);
       closeFuture = closeRequest.getFuture();
       closeFuture.addListener(
           new DbListener<Void>() {
             @Override
             public void onCompletion(DbFuture<Void> future) {
               MySqlConnection.this.connectionManager.removeConnection(MySqlConnection.this);
             }
           });
       if (closeMode == CloseMode.CANCEL_PENDING_OPERATIONS) {
         forceCloseOnPendingRequests();
       }
       forceQueRequest(closeRequest);
       return closeFuture;
     } else {
       return closeFuture;
     }
   }
 }
Esempio n. 5
0
 @Override
 public DbSessionFuture<PreparedUpdate> prepareUpdate(String sql) {
   checkClosed();
   return (DbSessionFuture) queRequest(MySqlRequests.prepareQuery(sql, this)).getFuture();
 }
Esempio n. 6
0
 @Override
 public DbSessionFuture<Result> executeUpdate(String sql) {
   checkClosed();
   return (DbSessionFuture) queRequest(MySqlRequests.executeUpdate(sql, this)).getFuture();
 }