解决JDBC连接MYSQL发出的警告:Sun May 03 16:39:29 CST 2020 WARN: Establishing SSL connection without server‘s i

在用JDBC链接MYSQL时出现的:Sun May 03 16:39:29 CST 2020 WARN: Establishing SSL connection without server’s identity verification is not recommended. 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.如下图

如需解决需要在定义的URL加上"?useSSL=false"
未加前会出现上图错误:
未加前的
已加后:
已加后
连接成功:
未报错
具体请看原文:https://blog.youkuaiyun.com/dianyanxia/article/details/84026059
作者:说好今夜不点烟

Fri Mar 28 12:13:52 CST 2025 WARN: Establishing SSL connection without server's identity verification is not recommended. 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. org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support. ### The error may exist in mapper/UserMapper.xml ### The error may involve com.sx.mapper.UserMapper.selectUserBvId ### The error occurred while executing a query ### Cause: java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support. at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:122) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:113) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:73) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:69) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53) at com.sun.proxy.$Proxy2.selectUserBvId(Unknown Source) at Test01.test1(Test01.java:13) at sun.ref
最新发布
03-29
### 解决 Eclipse 连接 MySQLSSL 警告的方法 当使用 JDBC 驱动程序连接到较新版本的 MySQL 数据库时,可能会遇到如下警告: > WARN: Establishing SSL connection without server’s identity verification is not recommended. 此警告表明,在没有服务器身份验证的情况下建立了 SSL 连接。对于开发环境而言,通常可以选择关闭 SSL 或者忽略该警告。 为了消除上述警告信息,可以在数据库 URL 中添加 `useSSL=false` 参数来显式禁用 SSL 连接[^1]。具体操作方法如下所示: #### 修改数据源配置 假设当前的数据源配置位于应用程序中的某个位置,那么需要调整其 URL 字符串部分。以下是修改后的代码片段示例: ```java // 创建一个新的数据源配置对象实例 DataSourceConfig dsc = new DataSourceConfig(); // 设置完整的 JDBC URL 地址,并附加 useSSL=false 参数以防止 SSL 提示 dsc.setUrl("jdbc:mysql://localhost:3306/your_database_name?useSSL=false"); // 继续设置其他必要的属性... dsc.setDriverName("com.mysql.cj.jdbc.Driver"); dsc.setUsername("your_username"); dsc.setPassword("your_password"); dsc.setDbType(DbType.MYSQL); mpg.setDataSource(dsc); ``` 请注意,URL 的参数之间应当由问号 (`?`) 和与号 (`&`) 正确分隔开;首次追加自定义参数时应确保前面有一个问号[^4]。 另外,如果正在使用的 MySQL 版本较高(例如 5.7 及以上),则可能还需要指定字符编码等额外参数以确保兼容性和性能优化。此时可进一步扩展 URL 如下形式: ```plaintext jdbc:mysql://localhost:3306/your_database_name?useUnicode=true&characterEncoding=UTF-8&useSSL=false ``` 这样做不仅解决SSL 警告问题,同时也保障了字符串处理的一致性[^2]。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值