连接mysql时出现的异常信息:(com.mysql.cj.exceptions.WrongArgumentException: Malformed database URL, failed to parse the connection string near ';allowMultiQueries=true')


连接mysql库报的异常信息: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 ';allowMultiQueries=true'.

解决方案:

连接的mysql是8.0.11版本,首先更新mysql驱动到对应版本

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.11</version>
</dependency>
//原来的URL
private static final String JDBC_URL = "jdbc:mysql://127.0.0.1:3306/db_ext_test?characterEncoding=UTF-8&amp;allowMultiQueries=true";

//改后的URL:
//    指定时区:serverTimezone=GMT
//    指定是否用ssl连接:useSSL=false
private static final String JDBC_URL1 = "jdbc:mysql://127.0.0.1:3306/db_ext_test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT";

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM