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

德鲁伊连接池报错,更改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 python使用pulp线性优化时报错
  • ¥15 开源或低价数据中台哪个最好
  • ¥15 arduino编程出现字符串疑似覆盖现象
  • ¥15 我的b站在没有碰到屏幕的情况下偶尔会自动跳出进度条,就像在屏幕上点了一下一样,但我并没有点。而且视频进度并没有变。这可能是什么原因造成的?
  • ¥30 STK matlab python仿真
  • ¥15 关于IMageEnView 图标定位问题
  • ¥20 求解答(matlab)
  • ¥30 ffmpeg库使用过程中遇到的问题
  • ¥15 pyqt5 中python如何通过Qtwebchannel主动发消息给web前端
  • ¥15 关于HTML中title获取xml内容的问题