1

I'm looking to set up Tomcat to use a JNDI pooled data source for a MySQL database. HikariCP seems to be the recommended choice recently (at least on StackOverflow).

The documentation helpfully lists the configuration (presumably for server.xml or context.xml) but divides into "Driver-based" and "DataSource-based". Couldn't find much more info about this - could anyone advise on how to make the choice?

Community
  • 1
  • 1
Steve Chambers
  • 37,270
  • 24
  • 156
  • 208

1 Answers1

1

All things being equal, I'd go with DataSource-based. With Driver-based the driver is basically wrapped as a DataSource internally -- so it adds an extra layer (thin though it may be).

However, all things are not always equal. Sometimes there are drivers that expose some settings as URL parameters but not as DataSource properties. Most drivers are good about equivalency. So, if you happen to need to tweak a setting that is only available as a URL parameter, you'll have no choice but to use the Driver-based approach.

brettw
  • 10,664
  • 2
  • 42
  • 59
  • Thanks, very helpful. Don't suppose you'd be able to comment specifically about [MySQL Connector/J](http://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html)? – Steve Chambers Sep 19 '14 at 14:34
  • The Connector/J documentation states, "Unless otherwise noted, properties can be set for a DataSource object or for a Connection object." However, I was unable to find any "noted" examples. I suspect that almost all properties are exposed on the DataSource. It's pretty easy to determine though, if you get an exception trying to use a specific property then you know it's not supported. :) – brettw Sep 20 '14 at 14:35