Ejemplo 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();
 }
Ejemplo 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;
   }
 }
Ejemplo 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();
   }
 }
Ejemplo 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;
     }
   }
 }
Ejemplo n.º 5
0
 @Override
 public DbSessionFuture<PreparedUpdate> prepareUpdate(String sql) {
   checkClosed();
   return (DbSessionFuture) queRequest(MySqlRequests.prepareQuery(sql, this)).getFuture();
 }
Ejemplo n.º 6
0
 @Override
 public DbSessionFuture<Result> executeUpdate(String sql) {
   checkClosed();
   return (DbSessionFuture) queRequest(MySqlRequests.executeUpdate(sql, this)).getFuture();
 }