Java – Eclipselink: How to check if connection pooling is used

Eclipselink: How to check if connection pooling is used… here is a solution to the problem.

Eclipselink: How to check if connection pooling is used

I use eclipselink

2.6.3 and I need to know exactly if the connection pool is created and used by eclipselink.

If persistence.xml I have the following settings

<property name="eclipselink.connection-pool.default.initial" value="5" />
<property name="eclipselink.connection-pool.default.min" value="10" />
<property name="eclipselink.connection-pool.default.max" value="10" />
<property name="eclipselink.jdbc.cache-statements" value="true" />

However, the logs for both cases are the same – when I use these settings and when I don’t:

[EL Finer]: connection: 2017-01-22 19:39:03.208--ServerSession(1440738283)--client acquired: 1177072083
[EL Finer]: transaction: 2017-01-22 19:39:03.218--ClientSession(1177072083)--acquire unit of work: 1482166692
[EL Finest]: query: 2017-01-22 19:39:03.239--UnitOfWork(1482166692)--Execute query ReadObjectQuery(...)
[EL Finest]: connection: 2017-01-22 19:39:03.243--ServerSession(1440738283)--Connection(2008547236)--Connection acquired from connection pool [read].
[EL Finest]: connection: 2017-01-22 19:39:03.243--ServerSession(1440738283)--reconnecting to external connection pool
[EL Fine]: sql: 2017-01-22 19:39:03.244--ServerSession(1440738283)--Connection(1590792382)-- SELECT ...
[EL Finest]: connection: 2017-01-22 19:39:03.25--ServerSession(1440738283)--Connection(2008547236)--Connection released to connection pool [read].
[EL Finer]: transaction: 2017-01-22 19:39:03.257--UnitOfWork(1482166692)--release unit of work
[EL Finer]: connection: 2017-01-22 19:39:03.257--ClientSession(1177072083)--client released

Can anyone say how to check the use of connection pooling.


EclipseLink can run in two modes. When you provide the JDBC URL and pool properties as you do, EclipseLInk creates and manages the connection pool. The implementation of the pool is org.eclipse.persistence.sessions.server.ConnectionPool. Another approach is to provide the data source through a JNDI reference or programmatically. The second option is commonly used for application servers, where the server manages the connection pooling and EclipseLink interrogates the data source when a new connection is needed.

If you want to check if the connection is in the pool, you will most likely have to do it from the database side. All databases allow you to view a list of connections and their IDs, as well as the queries they are currently executing. This should allow you to see if connections are being merged or if new connections are constantly being created. You can also set breakpoints in org.eclipse.persistence.sessions.server.ConnectionPool#acquireConnection() and step through the code.

Related Problems and Solutions