当前位置:Gxlcms > mysql > servlet用javabean连接访问mysql失败

servlet用javabean连接访问mysql失败

时间:2021-07-01 10:21:17 帮助过:33人阅读

mysqlservletjavabeanmvc

如果用java application连接wamp的mysql的话可以访问,但是换成servlet来访问就失败了
导入驱动包了,也把驱动包放入tomcat了,也改了mysql里面的服务时间了。
用php的话可以成功访问。
错误信息:
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
at com.mysql.jdbc.MysqlIO.(MysqlIO.java:343)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2132)
... 66 more
........
.........
后面省略

查了好多方法,都没用,求各位帮个忙啊

人气教程排行