A function is provided in the JDBC2.0 Optional Package for pooling connections to a database. An overview of connection pooling is provided below:
- Connection pooling has no effect on existing applications. This means that applications do not need to be aware of connection pooling. However, this assumes that the database is not connected by DriverManager, but rather by DataSource and JNDI provided by the JDBC2.0 Optional Package.
- The connection pooling function itself is outside the functional scope of the JDBC specifications. This is intended to allow the user to select a desired connection pooling function when building a system (the user can create one, use one provided by an APServer vendor, or use one provided by a JDBC vendor).
- With the connection pooling function, the Datasource class can be used as an interface with applications. This DataSource class is different from the DataSource class provided by the JDBC driver.
- With the JDBC driver, the ConnectionPoolDataSource class and PooledConnection class can be used as an interface with the connection pooling function.
- The ConnectionPoolDataSource class provided by the JDBC driver can use the connection information setting and acquisition methods in the same way as the Datasource class provided by the JDBC driver.
Table 16-11 shows classes related to connection pooling.
Table 16-11 Classes related to connection pools
Class |
Overview |
javax.sql.DataSource |
- Provided by a connection pooling function.
- Used as the interface to applications during database connection.
- Normally, connection pools are controlled in this class.
- Normally, registered in JNDI for use.
- Different from the DataSource class provided by the JDBC driver.
|
javax.sql.ConnectionPoolDataSource |
- Provided by the JDBC driver.
- Can use a method for setting/acquiring connection information necessary for database connection.
- Normally not used directly from an application, and is used by a connection pooling function.
- Normally, registered in JNDI for use.
- A connection pooling function acquires a PooledConnection object from this class of objects.
|
javax.sql.PooledConnection |
- Provided by the JDBC driver.
- Normally not used directly from an application, and is used by a connection pooling function.
- A connection pooling function targets this class of objects for pooling.
- A connection pooling function acquires a Connection object to be used by an application from this class of objects.
|
javax.sql.ConnectionEventListener |
- Provided by a connection pooling function.
- A connection pooling function senses a connection pooling trigger by detecting a disconnection or SQL error through this class of objects.
|
Depending on the JDK version, the interface definition of the classes shown in Table 16-11 might not be included in the JDK standard; you will need to check the JavaSoft website if you intend to use the connection pooling function.
The following are the package name and class names of the classes provided by the JDBC driver and shown in Table 16-11.
- Package name: JP.co.Hitachi.soft.HiRDB.JDBC
- ConnectionPoolDataSource class name: JdbhConnectionPoolDataSource
- PooledConnection class name: JdbhPooledConnection
Note that the setting of the connection information of the ConnectionPoolDataSource class provided by the JDBC driver is the same as the setting of the connection information of the DataSource class provided by the JDBC driver.
All Rights Reserved. Copyright (C) 2007, Hitachi, Ltd.