Class ConnectionContext

java.lang.Object
org.deltava.jdbc.ConnectionContext
Direct Known Subclasses:
HTTPContext, TaskContext

public abstract class ConnectionContext extends Object
A Context object that allows fetching of connections from a JDBC connection pool.
Since:
1.0
Version:
11.4
Author:
Luke
  • Constructor Details

    • ConnectionContext

      public ConnectionContext()
  • Method Details

    • getConnection

      Reserves a JDBC Connection from the connection pool.
      Returns:
      a JDBC Connection
      Throws:
      ConnectionContext.ConnectionPoolException - if an error occurs
      IllegalStateException - if a connection has already been reserved by this context
      See Also:
    • hasConnection

      public boolean hasConnection()
      Returns whether a JDBC connection has been reserved by this context.
      Returns:
      TRUE if a Connection has been reserved, otherwise FALSE
    • getDB

      public String getDB()
      Returns the default database name.
      Returns:
      the database name
    • setDB

      public void setDB(String dbName)
      Updates the default database name.
      Parameters:
      dbName - the database name
    • startTX

      public void startTX() throws TransactionException
      Starts a JDBC transaction block, by turning off autoCommit on the reserved Connection.
      Throws:
      IllegalStateException - if no JDBC Connection is reserved
      TransactionException - if a JDBC error occurs
    • commitTX

      public void commitTX() throws TransactionException
      Commits the current JDBC transaction.
      Throws:
      IllegalStateException - if no JDBC Connection is reserved
      TransactionException - if a JDBC error occurs
    • rollbackTX

      public void rollbackTX()
      Rolls back the current JDBC transaction. This will consume all exceptions.
    • release

      public long release()
      Returns a JDBC Connection to the connection pool.
      Returns:
      the time the connection was in use, in milliseconds