Hi,

We are running a number of TomEE servers and most of them are using JDBC to 
access Db2 for z/OS. The problem we see is that the connection pooling is 
sending a lot of validation queries to the database server. I would say, 
unneccesarily. To my knowledge there is a validation method called 
Connection.isValid in all JDBC 4.0 based JDBC drivers. This moves the 
responsibility to check if a connection is valid to the JDBC driver and it's up 
to the driver development to implement an efficient way to check the validity. 
The Oracle JDBC driver is doing the check by excuting an OPING lightweight RPC 
call to the database server, and the IBM JDBC driver is doing the equivalent by 
executing its very similar DRDA PING. This is the way to avoid unneccessary and 
inefficient validation queries.

What about TomEE?

According to an example in the TomEE documentation we took away the 
validationQuery and the configuration then looked like this.

    testOnBorrow = true
    testOnReturn = false
    testWhileIdle = false
    validationQuery =

That gave us the following exception.

OriginalError:java.sql.SQLException
Stacktrace:   java.sql.SQLException: Failed to validate a newly established 
connection.
at 
org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:848)
at 
org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:660)
at 
org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:198)
at 
org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:132)

Logically this is the result of the TomEE connection pooling to being unable to 
use an empty value in validationQuery to do its own validation. Obviously, the 
Connection.isValid is not used for the testOnBorrow.

So, what's my question?

I want to know whether the testOnBorrow can be set to false to get rid of the 
validation query behaviour. And if so, will TomEE connection pooling make use 
of the Connection.isValid method in the JDBC driver so that it is guaranteed to 
get a valid connection?

Many thanks in advance, Len

Lennart Henang, Skandia




________________________________
Bolag inom Skandiakoncernen, dess organisationsnummer och säte hittar du här 
https://skandia.se/om-oss/om-skandia/det-har-ar-skandia/

Reply via email to