Setting JDBC to use mySQL

December 5, 2010

To use mySql in your java projects in eclipse first go to http://dev.mysql.com/downloads/connector/j/ and download the connector, for example:

  • mysql-connector-java-5.1.13-bin.jar

Finally copy it to your lib folder, for example:

  • path-to-your-workspace/your-workspace-name/WebContent/WEB-INF/lib

Go to the eclipse, right button on the project name and select “Refresh”.

Pay atention, to use the new imported jar you have to add one of the following imports to your classes:

  • import com.mysql.jdbc.Driver;
  • import com.mysql.jdbc.*;