dby12348 2021-12-24 09:17 采纳率: 42.9%
浏览 38
已结题

这是什么原因,怎么解决啊?

问题遇到的现象和发生背景

银行管理系统,可以出GUI界面,但是写不进数据

问题相关代码,请勿粘贴截图
        //1.注册驱动  
 String driverClassName = "com.mysql.jdbc.Driver";  
 Class.forName("com.mysql.jdbc.Driver");  
         //2.连接数据库   
 Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3308/ren?useUnicode=true&characterEncoding=UTF-8","root","1234"); 
运行结果及报错内容

Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class is com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
com.mysql.cj.jdbc.exceptions.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.

我的解答思路和尝试过的方法
我想要达到的结果
  • 写回答

2条回答 默认 最新

  • 燕_青 2021-12-24 09:21
    关注

    你的MySQL是8.+版本的,需要用com.mysql.cj.jdbc.Driver这个驱动,但是用5.+版本的驱动也没问题,不算错误,一个告警信息吧

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 1月1日
  • 已采纳回答 12月24日
  • 创建了问题 12月24日