I have been using Tomcat with MySQL for a while, I remember when I first started using Tomcat, it took me a while to make my JSP script connect to MySQL using Connector/J.
1. Locate your Tomcat directory. If you have the recent version of Tomcat installed, you should be able to locate your Tomcat webapps folder:
for my Tomcat 5.5 installation, it looks like: tomcat5.5-webapps/
for my previous Tomcat 5 installation, it looks like: tomcat5/webapps/
2. Create a folder in your webapps, for instance: tomcat5.5-webapps/test/ or tomcat5/webapps/test/
3. Download Connector/J at http://dev.mysql.com/downloads/connector/j/5.1.html
4. Create a directory tomcat5.5-webapps/test/WEB-INF/lib/ or tomcat5/webapps/test/WEB-INF/lib/
5. Unzip or Untar the file, and copy the file mysql-connector-java-5.1.6-bin.jar
6. Paste it inside tomcat5.5-webapps/test/WEB-INF/lib/ or tomcat5/webapps/test/WEB-INF/lib/
7. Now create a test file named sql.jsp inside tomcat5.5-webapps/test/ or tomcat5/webapps/test/
8. Point browser to the url http://localhost:8080/test/sql.jsp, you should be able to see if it’s sucessfully connected to the MySQL database.











































#1 by jakub88 on September 17, 2008 - 8:24 am
This is so easy to follow, it will be better to talk more about the test script, it may be unclear to some people. thanks for your post!