The ConnectionEventListener interface receives ConnectionEvent objects from PooledConnection objects when a connection closes or a connection error occurs. The connection cache module should have a class that implements the standard ConnectionEventListener interface. In Figure 1, the PoolingVendorConnectionCache class is used as a simple way to convey this concept. Usually, a connection cache module contains one or multiple classes. The pooling vendor determines how these components will interact. The JDBC 3.0 API does not specify the interfaces to be used between the DataSource object and the connection cache. The pooling vendor's class uses the JDBC driver's PooledConnectionDataSource object to create the PooledConnections that the pool manages. This interface is the entry point that allows interaction with their pooling module. A PooledConnection object maintains the physical connection to the database the Connection object created by the PooledConnection object is simply a handle to the physical connection.Ī third-party vendor must provide a class that implements the DataSource interface. A PooledConnection object acts as a "factory" that creates Connection objects. This interface allows third-party vendors to implement pooling on top of their JDBC drivers. The ConnectionPoolDataSource interface acts as a "factory" that creates PooledConnection objects.Ī JDBC driver vendor must provide a class that implements the standard PooledConnection interface. This interface provides hooks that third-party vendors can use to implement pooling as a layer on top of their JDBC drivers. JDBC 3.0 Connection Pooling ArchitectureĪ JDBC driver vendor must provide a class that implements the standard ConnectionPoolDataSource interface. The JDBC 3.0 API specifies a ConnectionEvent class and the following interfaces as the hooks for any connection pooling implementation:įigure 1. In this way, third-party vendors or users can implement the specific caching or pooling algorithms that best fit their needs. The JDBC 3.0 API provides a general framework with "hooks" to support connection pooling rather than specifying a particular connection pooling implementation. Once a DataSource object is registered, the application retrieves it from the JNDI naming service in the standard way. A DataSource object registers with a JNDI naming service. A class implementing the DataSource interface may or may not provide connection pooling. To facilitate connection reuse, a memory cache of database connections, called a connection pool, is maintained by a connection pooling module as a layer on top of any standard JDBC driver product.Ĭonnection pooling is performed in the background and does not affect how an application is coded however, the application must use a DataSource object (an object implementing the DataSource interface) to obtain a connection instead of using the DriverManager class. Connection pooling means that connections are reused rather than created each time a connection is requested. In this type of environment, performance can be improved significantly when connection pooling is used. Establishing JDBC connections is resource-expensive, especially when the JDBC API is used in a middle-tier server environment, such as when DataDirect Connect for JDBC or DataDirect SequeLink for JDBC is running on a Java-enabled web server.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |