Alexis
Alexis

Reputation: 518

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{
        try{
            Class.forName("com.mysql.jdbc.Driver");
            con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","");
            pst.con.prepareStatement("insert into employee values(?,?,?)");
        }
        catch(Exception e{
            e.printStackTrace();
        }

    }

Upvotes: 0

Views: 77

Answers (2)

leldo
leldo

Reputation: 386

You can try a jmap -histo <PID> if you have jmap on your system to make sure your have MySQL driver class actually loaded .

While your application is running you can also try something like lsof |grep ".*mysql.*jar" to see if there's a jar but remember you could have sources somewhere too. (in that case just grep or findit )

Upvotes: 0

Drew Wills
Drew Wills

Reputation: 8446

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?

UPDATE

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?

Upvotes: 1

Related Questions