Alexis Alexis - 3 months ago 28
Java Question

mysql-connector strange behaviour in Tomcat

I am trying to deploy an app with tomcat.Everything works fine, except that i expected to have an error after deleting the connector file(mysql-connector-java-5.1.40) from the WEB-INF>lib directory, but,surprise, is still working without it. So, my question is if Tomcat is saving the conector elsewhere(i ve searched in Tomcat directories and found nothing). To start the Tomcat i use the startup.bat from bin directory of Tomcat.
My simple code for mysql db connection:

public void jspInit() throws JSPException{
pst.con.prepareStatement("insert into employee values(?,?,?)");
catch(Exception e{



If you left Tomcat running as you deleted the MySQL driver jar, Tomcat will nevertheless have the Java bytecode for it loaded in the JVM. Did you restart Tomcat when you deleted the jar?


Look for...

  • A copy of the JDBC driver jar in some shared classpath location, e.g. Tomcat/shared/lib
  • A second copy of the JDBC driver jar (with a different name) in your webapp
  • Do you perhaps have a CLASSPATH environment variable set on this machine? Perhaps from another project?