Package com.portal.pcm.jdbc
Class JDBCPool
java.lang.Object
com.portal.pcm.jdbc.JDBCPool
JDBCPool is a simple class that wraps the core Oracle JDBC Connection Pool and provides for
initialization from a simple configuration object.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionJDBCPool(String poolName, Configuration cfg) Constructor for a JDBCPool which will determine the schema from the configuration ...JDBCPool(String poolName, Configuration cfg, long schemaId) Constructor for a JDBCPool which will determine the schema passed to it ... -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Destroy the pool ...voidclose(Connection conn) voidclose(Connection conn, PreparedStatement stmt) voidclose(Connection conn, PreparedStatement stmt, ResultSet rs) Helpers for tidying-up the closure of SQL resources ...voidclose(PreparedStatement stmt) booleanDisable server output on a given connectionbooleanenableServerOutput(Connection conn, int limit) Enable server output for debug on a given connectionGet a connection from the pool and make sure it has AutoCommit enabled (this is our default)getConnection(boolean autoCommit) Get a connection from the pool and make sure it has AutoCommit enabled/disabled ...oracle.ucp.UniversalConnectionPoolgetPool()Get the underlying pool ...longGets the BRM database schema number of the current schema to which this pool is connected ...Gets the BRM database schema number to which this pool is connected as a string.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.voidlogServerOutput(Connection conn) Log the server output that has been accumulated to the diagnstic log.voidlogServerOutput(Connection conn, int linesToFetch) Log the server output that has been accumulated to the diagnstic log.voidRelease a connection back to the pool ...booleantest(int numConnections, int numIterations) Test the JDBC pool by retrieving connections, executing a little query and restoring the connection to the pool.toString()String representation of the pool ...booleanvalidateSchemaId(long schemaId) Check that the schema ID in the database we're connecting to is actually correct ...
-
Constructor Details
-
JDBCPool
public JDBCPool(String poolName, Configuration cfg) throws JDBCPoolException, ConfigurationException Constructor for a JDBCPool which will determine the schema from the configuration ...- Parameters:
poolName- A name one can use to refer to this pool in logs etc.cfg- The configuration for setting up this pool- Throws:
JDBCPoolExceptionConfigurationException
-
JDBCPool
public JDBCPool(String poolName, Configuration cfg, long schemaId) throws JDBCPoolException, ConfigurationException Constructor for a JDBCPool which will determine the schema passed to it ...- Parameters:
poolName- A name one can use to refer to this pool in logs etc.cfg- The configuration for setting up this poolschemaId- The schema we are expecting to connect to (can be 0 to default to 1 for backwards compatibility)- Throws:
JDBCPoolExceptionConfigurationException
-
-
Method Details
-
getConnection
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
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
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 usenumIterations- how many iterations of the test to perfom
-
close
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- connectionstmt- an (optional) prepared statementrs- an (optional) result set
-
close
-
close
-
close
-
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 caughtconn- Connection on which the exception was raisedstmt- Statement which was being executedlogIt- 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
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
Gets the BRM database schema number to which this pool is connected as a string.- Returns:
- the BRM schema number
- Throws:
SQLException
-
enableServerOutput
Enable server output for debug on a given connection- Parameters:
conn- The connection on which we're enabling server outputlimit- Limit to set for output buffer (if 0, the limit will be set to unlimited)- Returns:
- whether the output was enabled or not
-
disableServerOutput
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
Log the server output that has been accumulated to the diagnstic log.- Parameters:
conn- Connection from which to retrieve serveroutput
-
logServerOutput
Log the server output that has been accumulated to the diagnstic log.- Parameters:
conn- Connection on which to enable/disable serveroutputlinesToFetch- Number of lines of output to try and retrieve in each fetch
-
toString
String representation of the pool ...
-