1

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?

José Ricardo Pla
  • 1,043
  • 10
  • 16
david webber
  • 518
  • 1
  • 5
  • 13
  • Pax jdbc does not use a BasicDataSource so I am not sure if you can set this parameter at all. – Christian Schneider Jun 01 '15 at 13:52
  • Thank you for the reply. Do you know of an equivalent property, or another way to solve the problem? Most datasources I've looked at (Hikari, BasicDataSource, C3PO) have a way of specifying a lightweight query to periodically test the underlying connections before handing them over to the application. – david webber Jun 01 '15 at 14:12

1 Answers1

2

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

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64
  • That's exactly what I need. Thanks. Looking forward to the next release! – david webber Jun 01 '15 at 16:49
  • I added the code for this now and resolved the issue above. So next release should have it. I would appreciate if you could check out the pax-jdbc source and build/test it for your case. – Christian Schneider Jun 02 '15 at 08:25
  • Thanks for doing it so fast. I've checked out, compiled and tested, and the fix seems to work. I've debugged karaf, and I can see the validation query is getting set on the factory correctly. Not so easy to simulate the idle timeouts, but I'm confident that everything is working properly on your side. Thanks again. – david webber Jun 02 '15 at 15:09