欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

servlet用javabean连接访问mysql失败

程序员文章站 2022-03-18 08:09:29
...
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
........
.........
后面省略

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