skip to main content
About the Driver : Using the Driver : Connection Pool Manager : How Connection Pooling Works : Using a Connection Pool Data Source Object
  
Using a Connection Pool Data Source Object
Once a PooledConnectionDataSource object has been created and registered with JNDI, it can be used by your JDBC application as shown in the following example:
Context ctx = new InitialContext();
ConnectionPoolDataSource ds =
(ConnectionPoolDataSource)ctx.lookup("EmployeeDB");
Connection conn = ds.getConnection("domino", "spark");
The example begins with the intialization of the JNDI environment. Then, the initial naming context is used to find the logical name of the JDBC data source (EmployeeDB). The Context.lookup method returns a reference to a Java object, which is narrowed to a javax.sql.ConnectionPoolDataSource object. Next, the ConnectionPoolDataSource.getPooledConnection() method is called to establish a connection with the underlying database. Finally, the application obtains a connection from the ConnectionPoolDataSource.