mysql 8 jdbc connection error: Caused by: java.sql.SOLNonTransientConnectionException: Cannot load connection clas

Problem symptoms: As shown in the figure below:

 The error message is:

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)

and

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)

This problem occurred when I deployed an application that was originally mysql5.5 and needed to be deployed in a mysql8 environment. Because the application uses the mysql5 driver by default, and the application itself cannot place two mysql at the same time. jdbc driver, so I replaced the mysql5 driver in the original application's lib directory with the mysql8 driver (the driver can be downloaded from the official website or from here: (18 messages) Suitable for Mysql8 The navicat tool and jdbc connection driver-MySQL document resources-CSDN library are all acceptable), and the driver information in the connection string was changed:

Change the driver information to: driver-class-name:com.mysql.cj.Driver. Other information is the same as mysql 5.5. 

Then this problem occurred. After searching for information, I found that it was because of the unrecognized encoding & in the connection string url. I changed the link information to the following:

Also:

 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

 The problem is solved.

Guess you like

Origin blog.csdn.net/yeyuningzi/article/details/127350733