This article illustrates the steps to use Oracle Universal Connection Pool (UCP) with the Spring framework, using a sample application built using the JDBC template.
Assume there is a simple table EMP in the database with a single column “name” that is loaded with employee information (i.e., employee names).
Consider the following example DAO class in the package “test”:
The following is an example of the Row mapper implementation class for the EMP table:
The following class is the example of a java class that uses the JDBC Template for implementing the business logic:
The XML configuration file should specify UCP's oracle.ucp.jdbc.PoolDataSourceImpl as the data source class along with relevant connection pool properties, such as the initial-pool-size, max-pool-size, etc. For this sample, the XML configuration file is named "HelloAppConf.xml".
The main application code looks like the following. The application using the JDBC template will internally use the Universal Connection Pool (UCP) for connection check-outs and check-ins.