Connection pooling, Connection pooling using apache c3p0, Recommendations – HP Integrity NonStop J-Series User Manual

Page 72: Tuning connection pool

Advertising
background image

might be a good approach. Being able to set the transaction name explicitly is also something
that can only be done using the programmatic approach to transaction management.

2.

If your application has numerous transactional operations, declarative transaction management
is usually worthwhile. It keeps transaction management out of business logic, and is not difficult
to configure. When using the Spring framework, rather than EJB CMT, the configuration cost
of declarative transaction management is greatly reduced.

Connection Pooling

Connection Pooling is a cache of database connections maintained in the database memory so
that the connections can be reused when the database receives future requests for data. Every time
a database connection needs to be established, a request is made to pool or any object that holds
all the connections. Once that particular database activity is completed, the connection is returned
to the pool.

Many vendors provide their own customized Datasource Interfaces. However, we recommend the
use of Apache C3P0 as the Datasource Interface to be used with Spring applications. Spring
framework distribution contains the necessary files to use Apache C3P0 as the Datasource Interface
for connection pooling.In this section, we will discuss the steps to configure connection pooling in
your application using Apache C3P0.

Connection Pooling using Apache C3P0

C3P0 is an easy-to-use library for augmenting traditional (DriverManager-based) JDBC drivers with
JNDI-bindable DataSources, including DataSources that implement Connection and Statement
Pooling, as described by the jdbc3 spec and jdbc2 std extension.

To configure connection pooling using Apache C3P0, complete the following steps:-

1.

Add the c3p0-0.9.1.2.jar in your application CLASSPATH.

NOTE:

c3p0-0.9.1.2.jar

is available along with the Spring distribution package at

<Spring Home>/lib/c3p0

directory.

2.

Add the following basic configurations in applicationcontext.xml of your Spring application
to configure Apache C3P0 connection pooling:

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">

NOTE:

C3P0 is tunable and offers a number of configuration parameters.

For more information on C3P0 configuration, see

http://sourceforge.net/projects/c3p0

.

For the complete list of parameters, see

http://www.mchange.com/projects/c3p0/

index.html#appendix_a

Recommendations

Connection Pooling mechanism should be used when your application:

Cannot handle the overhead of obtaining and releasing connections frequently.

Requires JTA transactions

Does not manage the specifics of creating a connection, such as the database name, username,
or password.

Tuning Connection Pool

Performance improvements can be made by correctly tuning the parameters on the connection
pool. This section details each of the properties found on the Connection Pooling and how they
can be tuned for optimal performance.

72

Configuring Spring Applications on NonStop Systems

Advertising
This manual is related to the following products: