连接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";

 

posted @ 2019-07-16 14:29  水痕灬  阅读(23738)  评论(0编辑  收藏  举报