ALGORITHM LOL 2022-08-15 08:51 采纳率: 78.6%
浏览 161
已结题

德鲁伊连接池报错,更改MySQL驱动后无效

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

最近再跟着韩顺平teacher的java课程学到满汉楼部分,在使用druid连接池连接数据库时报错,我参考了相关的教程将mysql驱动版本改为了8.0.11,后续报出如下错误:

javaagent:D:\OTHERS\software\IDEA\IntelliJ IDEA 2020.2.4\lib\idea_rt.jar=59639:D:\OTHERS\software\IDEA\IntelliJ IDEA 2020.2.4\bin" -Dfile.encoding=UTF-8 -classpath D:\OTHERS\Projects\IDEA_workspace\mhl\out\production\mhl;D:\OTHERS\Projects\IDEA_workspace\mhl\libs\commons-dbutils-1.3.jar;D:\OTHERS\Projects\IDEA_workspace\mhl\libs\druid-1.1.10.jar;D:\OTHERS\Projects\IDEA_workspace\mhl\libs\mysql-connector-java-8.0.11.jar com.hspedu.mhl.utils.Test
815, 2022 8:37:29 上午 com.alibaba.druid.pool.DruidDataSource error
严重: init datasource error, url: jdbc:mysql://localhost:3306/mhl?useSSL=false&serverTimezone=GMT%2B8
java.sql.SQLSyntaxErrorException: Unknown error 1049
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:118)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:862)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:444)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:230)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:226)
    at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1558)
    at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1623)
    at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:861)
    at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1229)
    at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1225)
    at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:90)
    at com.hspedu.mhl.utils.JDBCUtilsByDruid.getConnection(JDBCUtilsByDruid.java:36)
    at com.hspedu.mhl.utils.Test.main(Test.java:14)

815, 2022 8:37:29 上午 com.alibaba.druid.pool.DruidDataSource error
严重: {dataSource-1} init error
java.sql.SQLSyntaxErrorException: Unknown error 1049
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:118)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:862)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:444)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:230)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:226)
    at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1558)
    at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1623)
    at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:861)
    at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1229)
    at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1225)
    at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:90)
    at com.hspedu.mhl.utils.JDBCUtilsByDruid.getConnection(JDBCUtilsByDruid.java:36)
    at com.hspedu.mhl.utils.Test.main(Test.java:14)

815, 2022 8:37:29 上午 com.alibaba.druid.pool.DruidDataSource info
信息: {dataSource-1} inited
Exception in thread "main" java.sql.SQLSyntaxErrorException: Unknown error 1049
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:118)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:862)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:444)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:230)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:226)
    at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1558)
    at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1623)
    at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:861)
    at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1229)
    at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1225)
    at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:90)
    at com.hspedu.mhl.utils.JDBCUtilsByDruid.getConnection(JDBCUtilsByDruid.java:36)
    at com.hspedu.mhl.utils.Test.main(Test.java:14)

Process finished with exit code 1

研究好久不知道是什么问题,还请大家指点指点

以下是相关配置文件与代码

img

druid.propertites

#key=value
driverClassName=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/mhl?useSSL=false&serverTimezone=GMT%2B8
username=root
password=hsp
#initial connection Size
initialSize=10
#min idle connecton size
minIdle=5
#max active connection size
maxActive=50
#max wait time (5000 mil seconds)
maxWait=5000

img

  • 写回答

4条回答 默认 最新

  • LiuDuanWu 2022-08-15 09:11
    关注

    检查一下 是不是数据库名打错了 mhl

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

报告相同问题?

问题事件

  • 系统已结题 8月23日
  • 已采纳回答 8月15日
  • 修改了问题 8月15日
  • 修改了问题 8月15日
  • 展开全部

悬赏问题

  • ¥15 YOLOv5在进行trainpy训练后为什么会出现这种情况(语言-python)
  • ¥15 关于远程桌面的鼠标位置转换
  • ¥15 MATLAB和mosek的求解问题
  • ¥20 修改中兴光猫sn的时候提示失败
  • ¥15 java大作业爬取网页
  • ¥15 怎么获取欧易的btc永续合约和交割合约的5m级的历史数据用来回测套利策略?
  • ¥15 有没有办法利用libusb读取usb设备数据
  • ¥15 为什么openeluer里面按不了python3呢?
  • ¥15 关于#matlab#的问题:训练序列与输入层维度不一样
  • ¥15 关于Ubuntu20.04.3LTS遇到的问题:在安装完CUDA驱动后,电脑会进入卡死的情况,但可以通过键盘按键进入安全重启,但重启完又会进入该情况!