Total Pageviews

Wednesday, November 23, 2011

Tomcat Mysql JDBC connection diagnosis

Tomcat Mysql JDBC connection diagnosis

In case of your web application is unable to connect to the Mysql database, chec the following:

  1. Is your Web.xml (/var/lib/tomcat6/webapps/<..>) refering to the correct IP or host name refering to Mysql server, with correct username/password
  2. MySql server is enabled with network access (/etc/mysql/my.cnf) and bind address as 0.0.0.0.
  3. check "mysql-connector-java-5.1.18-bin.jar" (version may vary) in path: "/usr/share/java".
  • /usr/share/tomcat6/lib shall have a softlink pointing to mysql-connector-java-5.1.18-bin.jar - 
  • command for softlink: ln -s /usr/share/java/mysql-connector-java-5.1.18-bin.jar mysql.jar - run this command inside /usr/share/tomcat6/lib
  • when you restart the tomcat server, check the catalina.out, does it showing any errors (/var/lib/tomcat6/logs/catalina.out)

NOTE: No CLASSPATH setting is required. It can be empty.
 
4. check from mysql database side- the username/password you are using to login has GRANT permission.

5.  check from the mysql server side- the mysql port (3306- default) is opened.



No comments: