Exception in thread “main“ java.lang.ClassNotFoundException: com.mysql.jdbc.Driver解决如此报错的问题

 1.首先缺少一个jar包,在所在Modulel里面添加一个jar包

下载地址:https://dev.mysql.com/downloads/file/?id=477058

添加jar包后,又出现这样的错误,

 

1.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.jdbc.Driver'这个数据驱动,新的数据库驱动是:The new driver class is `com.mysql.cj.jdbc.Driver'.

这个警告,不影响程序的运行,但是运行后控制台曝红,所改它。

在写程序时,注册数据库驱动时,写成最新的数据库驱动即可。

修改后:

 

 

2.Exception in thread "main" java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration propert

 这个是异常,服务器时区值无法识别或表示多个时区。

在连接的数据后面加上?serverTimezone=GMT,即可。

 添加后:

 做以上修改后,程序运行完美:

 

  • 4
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值