Class ConnectionHandlerSupport


  • public final class ConnectionHandlerSupport
    extends java.lang.Object
    Provides methods for getting ConnectionHandler for JDBC connections maintained by the IJC BaseDataSource.

    ConnectionHandler is 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 JDBC Connection object or it can be given the information for connecting to a database. IJC uses the concept of a DataSource which provides Connection objects. The ConnectionHandlerSupport class bridges these two concepts and allows to create ConnectionHandler instance initialized with a Connection object obtained from IJC DataSource. Having ConnectionHanlder is necessary when calling various JChem APIs.

    The 'unwrapping' that happens in ConnectionHandlerSupport makes sure that the original Connection object created by a JDBC driver is extracted from the various wrappers placed around it by the DataSource implementation and that the created ConnectionHandler contains this original Connection object and not the wrappers.

    Author:
    Martin Adamek
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static chemaxon.util.ConnectionHandler prepareConnectionHandler​(javax.sql.DataSource dataSource, java.lang.String jchemPropertiesTableName)
      TODO - this javadoc seems wrong.
      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.
      static void releaseConnectionHandler​(chemaxon.util.ConnectionHandler ch, javax.sql.DataSource src)
      Helper that releases the connection handler.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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. Use releaseConnectionHandler(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 -