问题现象:如下图所示:
错误信息为:
Caused by: java.sql.SOLNonTransientConnectionException: Cannot load connection class because of underlying exception: com.mysql.cj.e 32
xceptions.WrongArgumentException: Malformed database URL, failed to parse the connection string near ';characterEncoding=UTF-8' .
at com.mvsal.ci.idbc.excedtions.soLError.createSOLExcedtion(S0LError.iava:110) at com.mysql.cj.jdbc.exceptions.sQLError.creates0LException(S0LError.java:97) at com.mysql.ci.idbc.exceptions.soLError.createSOLException(SOLError.iava:89) at com.mysgl.ci.jdbc.exceptions.S0LError.createSOLException(S0LError.java:63) at com.mysql.ci.idbc.exceptions.SoLError.createSOLException(SOLError.java:73)
at com.mysql.ci.idbc.exceptions.SOLExceptionsMapping.translateException(SOLExceptionsMapping.iava:79) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:131) at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:219)un
at com.zaxxer.hikari.util.DriverDataSource.aetConnection(DriverDataSource.iava:138)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364) ni
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476) at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
at com.zaxxer.hikari.HikariDataSource.qetConnection(HikariDataSource.java:112)
at orq.hibernate.enqine.idbc.connections.internal.DatasourceConnectionProviderImpl.qetConnection(DatasourceConnectionProvide
rImpl.java:122)
at org.hibernate.engine.idbc.env.internal.JdbcEnvironmentInitiatorSConnectionProvider]dbcConnectionAccess.obtainConnection(]
dbcEnvironmentInitiator.java:180)
at orq.hibernate.resource.transaction.backend.idbc.internal.DdlTransactionIsolatorNonJtaImpl.qetIsolatedConnection(DdlTransa
ctionIsolatorNonJtaImpl.iava:43)
这个问题是在我部署原本是mysql5.5的应用,需要部署在mysql8的环境里 出现的,由于应用里默认放的是mysql5的驱动,并且应用本身没有办法同时放两个mysql的jdbc 驱动,所以我就把原来应用的lib目录下的 mysql5的驱动换成了mysql8 的驱动(驱动从官网下载或者从这里:(18条消息) 适用于Mysql8的navicat工具与jdbc连接驱动-MySQL文档类资源-CSDN文库均可),更改了连接字符串里的驱动信息:
将驱动信息改成了:driver-class-name:com.mysql.cj.Driver 其他信息均与mysql 5.5时相同
然后就出现了这个问题,经过查找资料发现是因为连接字符串url里的未识别编码&,将链接信息改成如下:
也即:
mysql数据库连接 v8
driver-class-name: com.mysql.cj.jdbc.Driver
url: idbc:mysql://192.168.214.173:3306/XXX?-
useUnicode=true&useSSL=false&characterEncoding=UTF-8
username: XXX
password:XXX
问题就解决了。