关于mysql驱动版本报错解决,Cause: com.mysql.jdbc.exceptions.jdbc4、Unknown system variable ‘query_cache_size

Error01 针对Maven项目依赖 mysql驱动版本不配置
querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.

关于mysql驱动版本报错解决,Cause: com.mysql.jdbc.exceptions.jdbc4、Unknown system variable ‘query_cache_size

ERR02 mysql驱动版本不配置
java.sql.Exception in thread “main” java.sql.SQLException: Unknown system variable ‘query_cache_size’

mysql-connecter-java的版本过低,数据库驱动程序与数据库版本不对应

`错误1:
java.sql.Exception in thread "main" java.sql.SQLException: Unknown system variable 'query_cache_size'
`错误2:
java.sql.SQLException: Unknown system variable 'language'

`原因
mysql-connecter-java的版本过低,数据库驱动程序与数据库版本不对应
`解决
1、更换工具包
mysql-connecter-java-5.1.47.jar 可以匹配 mysql8.0+

2、修改 pom文件
如mybatis使用 mysql-5.1.14的驱动程序,而mybatis配置的数据源连接的是 mysql-8.0.11 ,
修改 pom文件,如下:
<dependency>    
    <groupId>mysql</groupId>    
    <artifactId>mysql-connector-java</artifactId>   
    <version>8.0.11</version>  # 改成8.0+版本就可以了。
</dependency>

官方说法:
The query cache is deprecated as of MySQL 5.7.20, and is removed in MySQL 8.0. Deprecation includes query_cache_size.
意思:是查询缓存在MySQL 5.7.20中已弃用,在MySQL 8.0中已被移除。弃用包括query_cache_size。
Error03:jdbc 的 针对于mysql8+版本的URL SSL验证问题
WARN:hu Apr 15 12:27:34 CST 2021 WARN: Establishing SSL connection Establishing SSL connection without server’s identity verificati
hu Apr 15 12:27:34 CST 2021 WARN: Establishing SSL connection Establishing SSL connection without server's identity verificatio
According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

关于mysql驱动版本报错解决,Cause: com.mysql.jdbc.exceptions.jdbc4、Unknown system variable ‘query_cache_size

# 解决: 
# 在jdbcURL属性标签中添加这样的一行代码便会跳过SSL验证
?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false
例如:
Connection connect = DriverManager.getConnection( 
"jdbc:mysql://localhost:3306/数据库名?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false","root","root");
EER04:junit-4.11以上版本不在包含hamcrest。
java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
junit 单元测试报错java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing

Caused by: java.lang.ClassNotFoundException: org.hamcrest.SelfDescribing
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 19 more
原因

junit-4.11以上版本不在包含hamcrest。
解决方法

方法一:junit版本降到4.11以下

方法二:加入hamcrest-core-1.3.jar包
Err05 :属性集配置文件中路径不能有空格,否则报错: org.apache.ibatis.exceptions.PersistenceException ,Error building SqlSession.
org.apache.ibatis.exceptions.PersistenceException: 
### Error building SqlSession.
### The error may exist in configstatic/UserMapper.xml
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'configstatic/UserMapper.xml'. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias ' com.itheima.mb.pojo.User'.  Cause: java.lang.ClassNotFoundException: Cannot find class:  com.itheima.mb.pojo.User

文件路径不能有空格
上一篇:Cause: java.sql.SQLException: sql injection violation, syntax error: syntax error, expect ‘)‘


下一篇:com.microsoft.sqlserver.jdbc.SQLServerException: 必须执行该语句才能获得结果。