weixin_44749898 2021-06-05 18:17 采纳率: 96.2%
浏览 20
已结题

jdbc编译报错,以下是错误信息

a:查询学生信息  b:添加学生信息  c:修改学生信息  d:删除学生信息

请输入操作,abcd任选一项:a

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.

a:查询学生信息  b:添加学生信息  c:修改学生信息  d:删除学生信息 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)

at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1137)

at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:355)

at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2490)

at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2527)

at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2309)

at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)

at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

at com.mysql.jdbc.Util.handleNewInstance(Util.java:408)

at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:419)

at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:344)

at java.sql.DriverManager.getConnection(DriverManager.java:664)

at java.sql.DriverManager.getConnection(DriverManager.java:247)

at com.tedu.util.JdbcUtil.getConn(JdbcUtil.java:20)

at com.tedu.StudentManager.findAll(StudentManager.java:48)

at com.tedu.StudentManager.main(StudentManager.java:29)

Caused by: java.net.ConnectException: Operation timed out (Connection timed out)

at java.net.PlainSocketImpl.socketConnect(Native Method)

at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:476)

at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:218)

at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:200)

at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:394)

at java.net.Socket.connect(Socket.java:606)

at java.net.Socket.connect(Socket.java:555)

at java.net.Socket.<init>(Socket.java:451)

at java.net.Socket.<init>(Socket.java:261)

at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:258)

at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:305)

... 17 more

 

请输入操作,abcd任选一项:

 

 

  • 写回答

1条回答 默认 最新

  • 爀爀 2021-06-05 18:32
    关注

    你看看你MySQL开没开启

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 8月26日
  • 已采纳回答 8月18日

悬赏问题

  • ¥15 初学者用plt报错,求解答
  • ¥18 深度学习tensorflow1,ssdv1,coco数据集训练一个模型
  • ¥100 关于注册表摄像头和麦克风的问题
  • ¥30 代码本地运行正常,但是TOMCAT部署时闪退
  • ¥15 关于#python#的问题
  • ¥15 主机可以ping通路由器但是连不上网怎么办
  • ¥15 数据库一张以时间排好序的表中,找出多次相邻的那些行
  • ¥50 关于DynamoRIO处理多线程程序时候的问题
  • ¥15 kubeadm部署k8s出错
  • ¥15 Abaqus打不开cae文件怎么办?