Class JDBCPool

java.lang.Object
com.portal.pcm.jdbc.JDBCPool

public final class JDBCPool extends Object
JDBCPool is a simple class that wraps the core Oracle JDBC Connection Pool and provides for initialization from a simple configuration object.
  • Constructor Details

  • Method Details

    • getConnection

      public Connection getConnection() throws SQLException
      Get a connection from the pool and make sure it has AutoCommit enabled (this is our default)
      Returns:
      a Connection with auto-commit enabled
      Throws:
      SQLException
    • getConnection

      public Connection getConnection(boolean autoCommit) throws SQLException
      Get a connection from the pool and make sure it has AutoCommit enabled/disabled ...
      Parameters:
      autoCommit - Boolean to determine whether the returned connection has auto-commit set or not.
      Returns:
      a Connection with auto-commit enabled
      Throws:
      SQLException
    • releaseConnection

      public void releaseConnection(Connection c)
      Release a connection back to the pool ...
      Parameters:
      c - connection to release back to the pool
    • getPool

      public oracle.ucp.UniversalConnectionPool getPool()
      Get the underlying pool ...
    • close

      public void close()
      Destroy the pool ...
    • test

      public boolean test(int numConnections, int numIterations)
      Test the JDBC pool by retrieving connections, executing a little query and restoring the connection to the pool.
      Parameters:
      numConnections - the number of connection pool connections to use
      numIterations - how many iterations of the test to perfom
    • close

      public void close(Connection conn, PreparedStatement stmt, ResultSet rs)
      Helpers for tidying-up the closure of SQL resources ... IJH XXX - should probably be looking at using auto-closeable for this stuff ... Revisit ...
      Parameters:
      conn - connection
      stmt - an (optional) prepared statement
      rs - an (optional) result set
    • close

      public void close(Connection conn, PreparedStatement stmt)
    • close

      public void close(Connection conn)
    • close

      public void close(PreparedStatement stmt)
    • handleSQLException

      public ErrorType handleSQLException(Exception e, Connection conn, Statement stmt, JDBCPool.LogLevel logIt)
      Method to handle a SQLException and determine whether it is transient or not based on the list of SQL Error codes configured in the JDBCPool. This will return whether the error was transient or not and handle cancel/rollback.
      Parameters:
      e - Exception that has been caught
      conn - Connection on which the exception was raised
      stmt - Statement which was being executed
      logIt - flag to indicate that the exception should be logged (LOG_NONE, LOG_ERROR, LOG_EXCEPTION)
      Returns:
      Error type
    • getSchemaId

      public long getSchemaId()
      Gets the BRM database schema number of the current schema to which this pool is connected ...
      Returns:
      The BRM schema number to which we are connected
    • validateSchemaId

      public boolean validateSchemaId(long schemaId) throws SQLException
      Check that the schema ID in the database we're connecting to is actually correct ...
      Parameters:
      schemaId - the schema ID to validate
      Returns:
      true if the schemas match, false otherwise
      Throws:
      SQLException - if the query failed for some reason.
    • getSchemaString

      public String getSchemaString() throws SQLException
      Gets the BRM database schema number to which this pool is connected as a string.
      Returns:
      the BRM schema number
      Throws:
      SQLException
    • enableServerOutput

      public boolean enableServerOutput(Connection conn, int limit)
      Enable server output for debug on a given connection
      Parameters:
      conn - The connection on which we're enabling server output
      limit - Limit to set for output buffer (if 0, the limit will be set to unlimited)
      Returns:
      whether the output was enabled or not
    • disableServerOutput

      public boolean disableServerOutput(Connection conn)
      Disable server output on a given connection
      Parameters:
      conn - The connection on which we're disabling server output
      Returns:
      whether the output was disbled or not
    • logServerOutput

      public void logServerOutput(Connection conn)
      Log the server output that has been accumulated to the diagnstic log.
      Parameters:
      conn - Connection from which to retrieve serveroutput
    • logServerOutput

      public void logServerOutput(Connection conn, int linesToFetch)
      Log the server output that has been accumulated to the diagnstic log.
      Parameters:
      conn - Connection on which to enable/disable serveroutput
      linesToFetch - Number of lines of output to try and retrieve in each fetch
    • toString

      public String toString()
      String representation of the pool ...
      Overrides:
      toString in class Object