How does connection pooling work and why do I sometimes see only 1 DB connection ?

book

Article ID: 160601

calendar_today

Updated On:

Products

Data Loss Prevention Enforce

Issue/Introduction

How does Connection pooling work and why do I sometimes see only one database connection despite users working in parallel within the Symantec DLP UI ?

Resolution

The purpose of using connection pools is to avoid multiple connections going to a DB. It is very costly to establish the connections and would create a performance problem. By using connection pools, the JDBC driver opens a connection and creates a connection pool that will be used within the Vontu manager framework.

 

Details how connection pooling works and used concepts are outlined in http://download.oracle.com/docs/cd/B10501_01/java.920/a96654/connpoca.htm#1057365 .

 

Pooled connections--a pooled connection instance represents a single physical connection to a database, remaining open during use by a series of logical connection instances.

 

A logical connection instance is a simple connection instance (such as a standard Connection instance or an OracleConnection instance) returned by a pooled connection instance. Each logical connection instance acts as a temporary handle to the physical connection represented by the pooled connection instance.

 

It is at the discretion of the driver how much concurrency it allows and how many connections it would spawn to the DB. In most cases the JDBC drivers are using it in a dynamic fashion and if the open connection is unable to handle the concurrent threads it won’t spawn a new connection.

In other words, In general the connections to the DB are handled by the actual JDBC driver. If there is a need for multiple connections to be open, the driver would establish them.

 

See http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.html#02_14

 

The drivers create a number of different threads, but only on an as-needed basis. They do not create the threads unless your code makes use of the feature that depends on the thread. All of these threads are daemon threads.

 

Which means , unless required or explicitly created within your code, the JDBC driver will create initially only one connection.