首页 >数据库 >mysql教程 >servlet用javabean连接访问mysql失败

servlet用javabean连接访问mysql失败

WBOY
WBOY原创
2016-06-06 09:44:051352浏览

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
........
.........
后面省略

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

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn