mysql 8.0 java连接报错:Unknown system variable 'query_cache_size'
Posted testway
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql 8.0 java连接报错:Unknown system variable 'query_cache_size'相关的知识,希望对你有一定的参考价值。
java连接mysql 8.0.11报错
java.sql.SQLException: Unknown system variable ‘query_cache_size‘
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:545)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:513)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:115)
at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1983)
at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1936)
at com.mysql.cj.jdbc.StatementImpl.executeQuery(StatementImpl.java:1422)
at com.mysql.cj.jdbc.ConnectionImpl.loadServerVariables(ConnectionImpl.java:2831)
at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:2381)
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:1739)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1596)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:633)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:347)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:219)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
原因是mysql-connector-java的版本还是6.0.6,需要升级版本到8.0.11 ,这个报错就不存在了
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.11</version>
</dependency>
以上是关于mysql 8.0 java连接报错:Unknown system variable 'query_cache_size'的主要内容,如果未能解决你的问题,请参考以下文章
MySQL 8.0版本连接报错:Could not create connection to database server和Unsupported major.minor version 52.0