Class ConnectionHandlerSupport
- java.lang.Object
-
- com.im.commons.db.util.ConnectionHandlerSupport
-
public final class ConnectionHandlerSupport extends java.lang.ObjectProvides methods for gettingConnectionHandlerfor JDBC connections maintained by the IJCBaseDataSource.ConnectionHandleris a concept from JChem. It's basically a wrapper around a database connection. Its complexity comes from the fact that it can either be given a JDBCConnectionobject or it can be given the information for connecting to a database. IJC uses the concept of aDataSourcewhich providesConnectionobjects. TheConnectionHandlerSupportclass bridges these two concepts and allows to createConnectionHandlerinstance initialized with aConnectionobject obtained from IJCDataSource. HavingConnectionHanlderis necessary when calling various JChem APIs.The 'unwrapping' that happens in
ConnectionHandlerSupportmakes sure that the originalConnectionobject created by a JDBC driver is extracted from the various wrappers placed around it by theDataSourceimplementation and that the createdConnectionHandlercontains this originalConnectionobject and not the wrappers.- Author:
- Martin Adamek
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static chemaxon.util.ConnectionHandlerprepareConnectionHandler(javax.sql.DataSource dataSource, java.lang.String jchemPropertiesTableName)TODO - this javadoc seems wrong.static chemaxon.util.ConnectionHandlerprepareConnectionHandlerMutliConnectionNoTx(javax.sql.DataSource dataSource, java.lang.String schemaPlusProptable)Special case of creating a ConnectionHandler that only has connection details, not an actual physical connection.static voidreleaseConnectionHandler(chemaxon.util.ConnectionHandler ch, javax.sql.DataSource src)Helper that releases the connection handler.
-
-
-
Method Detail
-
releaseConnectionHandler
public static void releaseConnectionHandler(chemaxon.util.ConnectionHandler ch, javax.sql.DataSource src)Helper that releases the connection handler. It is just to centralize the processing
-
prepareConnectionHandler
public static chemaxon.util.ConnectionHandler prepareConnectionHandler(javax.sql.DataSource dataSource, java.lang.String jchemPropertiesTableName)TODO - this javadoc seems wrong. Connection is completely unwrapped? Prepares the ConnectionHandler. It uses Spring DataSourceUtils to obtain the connection, it does not directly pull Connection from the DataSource. In the case that a transaction is active, it wraps the Connection with a proxy that suppresses close() so that accidental call to ConnectionHandler.close() does no damage. UsereleaseConnectionHandler(chemaxon.util.ConnectionHandler, javax.sql.DataSource)to release resources associated with the ConnectionHandler including the connection
-
prepareConnectionHandlerMutliConnectionNoTx
public static chemaxon.util.ConnectionHandler prepareConnectionHandlerMutliConnectionNoTx(javax.sql.DataSource dataSource, java.lang.String schemaPlusProptable)Special case of creating a ConnectionHandler that only has connection details, not an actual physical connection. This is useful as it allows JChem to created new connections as it needs so that it can use multiple threads for things like Chemical terms column calculations and table regeneration. WARNING: ConnectionHandler created in this way MUST be closed using ConnectionHandler.close().- Parameters:
dataSource-schemaPlusProptable-
-
-