예제 #1
0
 @Override
 public DbFuture<PreparedUpdate> prepareUpdate(String sql) {
   checkClosed();
   final Request request = requestCreator.executePrepareUpdate(sql);
   queRequest(request);
   return (DbFuture<PreparedUpdate>) request.getToComplete();
 }
예제 #2
0
 @Override
 public DbFuture<Result> executeUpdate(String sql) {
   checkClosed();
   final Request request = requestCreator.executeUpdate(sql);
   queRequest(request);
   return (DbFuture) request.getToComplete();
 }
예제 #3
0
 @Override
 public <T> DbFuture<T> executeQuery(String sql, ResultHandler<T> eventHandler, T accumulator) {
   checkClosed();
   synchronized (lock) {
     final Request request = requestCreator.createQuery(sql, eventHandler, accumulator);
     queRequest(request);
     return (DbFuture<T>) request.getToComplete();
   }
 }
예제 #4
0
 @Override
 public DbFuture<Void> rollback() {
   checkClosed();
   synchronized (lock) {
     if (!isInTransaction()) {
       throw new DbException("Not currently in a transaction, cannot rollback");
     }
     final Request request = requestCreator.rollbackTransaction();
     queRequest(request);
     isInTransaction = false;
     return (DbFuture<Void>) request.getToComplete();
   }
 }
예제 #5
0
 @Override
 public void beginTransaction() {
   checkClosed();
   synchronized (lock) {
     if (isInTransaction()) {
       throw new DbException(
           "Cannot begin new transaction.  Current transaction needs to be committed or rolled back");
     }
     isInTransaction = true;
     final Request request = requestCreator.beginTransaction();
     queRequest(request);
   }
 }
예제 #6
0
 @Override
 public DbFuture<Void> close(CloseMode closeMode) throws DbException {
   synchronized (lock) {
     if (this.closeFuture != null) {
       return closeFuture;
     }
     if (closeMode == CloseMode.CANCEL_PENDING_OPERATIONS) {
       forceCloseOnPendingRequests();
     }
     Request request = requestCreator.createCloseRequest();
     forceQueRequest(request);
     closeFuture = (DefaultDbFuture<Void>) request.getToComplete();
     closeFuture.addListener(
         new DbListener<Void>() {
           @Override
           public void onCompletion(DbFuture<Void> future) {
             H2Connection.this.manager.removeConnection(H2Connection.this);
           }
         });
     return closeFuture;
   }
 }