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:
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.