简体   繁体   中英

Changing tomcat 6 to tomcat 7 Giving error

My application running well in tomcat 6 with this connection variable

Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/Travel","root","root");

I have already tried many places to solve this but I couldn't find solution. But in tomcat 7 when I try to use connection variable it return Null pointer Exception . Is there any way to change it in connection file?

Hads similar issue Tomcat7 with mysql-connector-java-5.1.26 that put in both my $CATALINA_HOME/lib and WEB-INF/lib, just in case. But it wouldn't find it until use either one of these two statements before getting the connection:

DriverManager.registerDriver(new com.mysql.jdbc.Driver ());

OR

Class.forName("com.mysql.jdbc.Driver");

then followup with removing mysql-connector-java-5.1.26 from $CATALINA_HOME/lib and the connection still works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM