@Override public <T> DbSessionFuture<T> executeQuery( String sql, ResultHandler<T> eventHandler, T accumulator) { checkClosed(); return (DbSessionFuture) queRequest(MySqlRequests.executeQuery(sql, eventHandler, accumulator, this)).getFuture(); }
@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; } }
@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(); } }
@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; } } }
@Override public DbSessionFuture<PreparedUpdate> prepareUpdate(String sql) { checkClosed(); return (DbSessionFuture) queRequest(MySqlRequests.prepareQuery(sql, this)).getFuture(); }
@Override public DbSessionFuture<Result> executeUpdate(String sql) { checkClosed(); return (DbSessionFuture) queRequest(MySqlRequests.executeUpdate(sql, this)).getFuture(); }