skip to main content
DataDirect tools : Connection Pool Manager : How connection pooling works : Using a connection pool DataSource object
  

Try DataDirect Drivers Now
Using a connection pool DataSource 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.