How to avoid jdbc data source to validate

Viewed 17

I need to avoid doing validation queries to my database. I tried different configurations (deleting validationQuery and putting testOnxxx to false), but nothing seems to work. I'm using Tomcat.

This is how I have configured my data source:

<Resource id="myDataSource" type="javax.sql.DataSource">
        alternateUsernameAllowed = false
        defaultAutoCommit = true
        initialSize = 2
        jdbcDriver = com.ibm.db2.jcc.DB2Driver
        jdbcUrl = jdbc:db2://myjdbcUrl
        maxActive = 15
        maxIdle = 15
        maxWait = 1
        minIdle = 0
        numTestsPerEvictionRun = 3
        password = xxxx
        passwordCipher = Static3DES
        testOnBorrow = false
        testOnReturn = false
        userName = myUser
        logValidationErrors = true
        removeAbandoned = true
        ignoreMe = maxWait
        connectionProperties = myConnectionProperties
        minEvictableIdleTimeMillis = 65000
        timeBetweenEvictionRunsMillis = 35000
        validationInterval = 35000
        testWhileIdle = false
        removeAbandonedTimeout = 65
        logAbandoned = true
        ignoreMe2 = timeBetweenEvictionRunsMillis
        ignoreMe3 = minEvictableIdleTimeMillis
</Resource>

What am I doing wrong?

If it's not possible, maybe an alternative can be to put a larger number on validationQuery, this should work?

1 Answers

A validation query is meant to be quick and immediate, not much burden to your database layer. When you use a connection pool, it's enabling the pool to ensure that it hands out a valid connection (because this connection might already be timed out). Without validation, you'd run into using closed connections way more often than you do with them.

I need to avoid doing validation queries to my database

I expect this to be an XY-problem - you somehow came up with this solution, but I highly doubt that it solves the underlying problem.

Related