简体   繁体   English

将tomcat 6更改为tomcat 7给出错误

[英]Changing tomcat 6 to tomcat 7 Giving error

My application running well in tomcat 6 with this connection variable 我的应用程序在tomcat 6中使用此连接变量运行良好

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 . 但是在tomcat 7中,当我尝试使用连接变量时,它返回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. Hads类似问题Tomcat7与mysql-connector-java-5.1.26一起放入我的$ CATALINA_HOME / lib和WEB-INF / lib,以防万一。 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. 然后从$ CATALINA_HOME / lib中删除mysql-connector-java-5.1.26,并且连接仍然有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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