This post originated from an RSS feed registered with Java Buzz
by Russell Beattie.
Original Post: MySQL JDBC Driver and Tomcat Pooling
Feed Title: Russell Beattie Notebook
Feed URL: http://www.russellbeattie.com/notebook/rss.jsp?q=java,code,mobile
Feed Description: My online notebook with thoughts, comments, links and more.
It turns out that the MysqlConnectionPoolDataSource is being called through a class called MysqlDataSourceFactory which takes the parameters in from the ResourceParams in the server.xml and uses that to instantiate the Pool. It turns out that it only was bothering with username, password, port and database name. That's it, no URL or any other params. If you check out the readme or documentation of the MySQL JDBC driver you'll see there's about 30 more parameters you can pass, including "autoReconnect", "useUnicode" and pool options like "max-connections" etc. For some reason those are *left out* of the 3.0 codebase.
So I implemented a factory myself and threw it into the /common/classes directory and it worked (it's running now). *THEN* as I'm writing this it dawns on me to check out the 3.11 Alpha build and sure enough, the magical missing URL parameter is in there. Doh! Now I wonder whether I should continue with my own rolled factory, or upgrade to a potentially unstable build of the driver. Urgh.
Anyways, for search engines in the future, here's how to set up the MySQL pool in Tomcat 5.0 using the 3.1 version of MySQL's Connector/J JDBC Driver: