skip to main content
Using the Driver : Connection Pool Manager : How Connection Pooling Works : Using a Connection Pool Data Source Object
  

Try DataDirect Drivers Now
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 DataSource (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. Then, the application obtains a connection from the ConnectionPoolDataSource.