How do you set a validationQuery when using karaf + Ops4j jdbc + apache DBCP?

746 Views Asked by At

I've followed the tutorial here: http://www.liquid-reality.de/display/liquid/2012/01/13/Apache+Karaf+Tutorial+Part+6+-+Database+Access which explains how to set up a datasource in Karaf using apache DBCP wrapped by Ops4J JDBC.

You can set properties on the underlying object pool using the "pool" property prefix, but there is no way I can see to set the "validationQuery" property, probably because this is not a property of the underlying pool, but the BasicDataSource itself. I need to set this property because I am experiencing connection timeouts on our dev server, which sometimes break our nightly integration tests.

Can this be done?

1

There are 1 best solutions below

3
On BEST ANSWER

I found a way to set the validation query independent from the BasicDataSource. There is org.apache.commons.dbcp2.PoolableConnectionFactory.setValidationQuery.

We use a PoolableManagedConnectionFactory internally in pax jdbc. Currently there is no way to set this property but I added a jira issue to add this option: https://ops4j1.jira.com/browse/PAXJDBC-70