您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

springBoot2.x启动项目报java.sql.SQLNonTransientConnectionException

bubuko 2022/1/25 20:09:48 java 字数 3228 阅读 1775 来源 http://www.bubuko.com/infolist-5-1.html

springBoot1.x升级到springBoot2.x,出现默认的mysql驱动包版本的问题,需要修改jdbc驱动类和连接字符串 ...

将项目从springBoot1.x升级到springBoot2.x,启动报错:

1 java.sql.SQLNonTransientConnectionException: Cannot load connection class because of underlying exception: com.mysql.cj.exceptions.WrongArgumentException: Malformed database URL, failed to parse the connection string near ‘;characterEncoding=UTF8&useSSL=true?autoReconnect=true‘.
2     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
3     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
4     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
5     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
6     at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
7     at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:79)
8     at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:131)
9     at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:219)

看提示报错原因是mysql的jdbc连接字符串不符合要求

修改成前面文章的url:MySQL的JDBC驱动(8.0版本)

1 jdbc:mysql://{ip}:{port}/{db}?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true

 再次启动,还是报错,看到有错误提示:

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.

很明显是jdbc驱动包没配对,修改之,再次启动成功

 

springBoot2.x启动项目报java.sql.SQLNonTransientConnectionException

原文:https://www.cnblogs.com/zhuitian/p/12373622.html


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶