使用java连接数据库以后显示“ Establishing SSL connection without server's identity verification is not recommended”的警告如何解决
今天写了一段查询数据库的操作,如下
package MySQL;
import java.sql.*;
public class MySQL {
//JDBC驱动名以及数据库URL
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String DB_URL = "jdbc:mysql://localhost:3306/test";
//数据库的用户名和密码
static final String USER = "root";
static final String PASS = "0825";
public static void main(String args[]) {
Connection conn = null;
Statement stmt = null;
try {
//注册JDBS驱动
Class.forName("com.mysql.jdbc.Driver");
//打开连接
System.out.println("连接数据库");
conn = DriverManager.getConnection(DB_URL, USER, PASS);
//执行查询
System.out.println(" 实例化Statement对象...");
stmt = conn.createStatement();
String sql;
sql = "select * from users";
ResultSet rs = stmt.executeQuery(sql);
//展开结果集数据库
while(rs.next()){
//通过字段见索引
int id = rs.getInt("id");
String name = rs.getString("name");
int age = rs.getInt("age");
//输出数据
System.out.println("Id:"+id);
System.out.println("名字:"+name);
System.out.println("年龄"+age);
}
//完成后进行关闭
rs.close();
stmt.close();
conn.close();
} catch (SQLException se) {
// 处理 JDBC 错误
se.printStackTrace();
} catch (Exception e) {
// 处理 Class.forName 错误
e.printStackTrace();
} finally {
// 关闭资源
try {
if (stmt != null) stmt.close();
} catch (SQLException se2) {
}// 什么都不做
try {
if (conn != null) conn.close();
} catch (SQLException se) {
se.printStackTrace();
}
System.out.println("Goodbye!");
}
}
}
表结构和表内容:


好,那么我们来看一下运行的结果:

没有影响显示,但是却出现了警告,网上查询资料,原来是需要在DB_URL后面加上参数:
// 加了 ?useUnicode=true&characterEncoding=utf-8&useSSL=false
static final String DB_URL = "jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false";
OK,成功运行,其实这个警告不影响使用,只是SQL版本的事情罢了
使用java连接数据库以后显示“ Establishing SSL connection without server's identity verification is not recommended”的警告如何解决的更多相关文章
- Java连接MySQL Warning: Establishing SSL connection without server's identity verification is not recommended
1. 数据库 1.1 创建表 在当前数据库students中,创建数据表student: mysql> create table student( ),#学生ID ),#学生姓名 -> a ...
- java链接Mysql出现警告: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
Java使用mysql-jdbc连接MySQL出现如下警告: Establishing SSL connection without server's identity verification is ...
- Java连接mysql——Establishing SSL connection without server's identity verification is not recommended.
Establishing SSL connection without server's identity verification is not recommended. 出现这个错误的原因是因为m ...
- Java连接MySQL报出警告 WARN: Establishing SSL connection without server's identity verification is not recommended.
很多人使用JDBC连接MySQL时报出警告: WARN: Establishing SSL connection without server's identity verification is n ...
- Java连接Mysql数据库警告: 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
详细错误: Establishing SSL connection without server's identity verification is not recommended. Accordi ...
- java运行jdk连接mysql出现了:Establishing SSL connection without server's identity verification is not recommended
注意:出现这类提示也不会影响对数据库的增删改查操作,所以不用紧张.. 在运行练习时出现下面的错误信息提示: Establishing SSL connection without server's i ...
- Wed Sep 19 20:48:46 CST 2018 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 mus
Wed Sep 19 20:48:46 CST 2018 WARN: Establishing SSL connection without server's identity verificatio ...
- 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 i
jdbc连接数据库候,对数据进行访问,访问正常当出现如下警告: WARN: Establishing SSL connection without server's identity verifica ...
- 【警告】WARN: Establishing SSL connection without server's identity verification is not recommended.
1.Java访问Mysql时出现如下警告: 2019-04-02 10:30:50.545 INFO 1290 --- [nio-8080-exec-1] com.zaxxer.hikari.Hika ...
随机推荐
- (笔记)Linux Root下的.gvfs出现异常解决办法
在linux系统下安装软件或复制文件的时候,复制不成功,出现错误如下: error: failed to stat /home/dade/.gvfs: Permission denied. 表面上看: ...
- SQL数据查询之——单表查询
一.SQL数据查询的一般格式 数据查询是数据库的核心操作.SQL提供了SELECT语句进行数据查询,其一般格式为: SELECT [ALL | DISTINCT]<目标列表达式>[,< ...
- django学习2 视图和模板
1 编写更多的视图 polls/views.py def detail(request, question_id): return HttpResponse("You're looking ...
- 针对程序集 'SqlServerTime' 的 ALTER ASSEMBLY 失败,因为程序集 'SqlServerTime' 未获授权(PERMISSION_SET = EXTERNAL_ACCESS)
错误: 针对程序集 'SqlServerTime' 的 ALTER ASSEMBLY 失败,因为程序集 'SqlServerTime' 未获授权(PERMISSION_SET = EXTERNAL_A ...
- (转)解决Win7/8硬盘占用高方案汇总
写在前面 在Windows7时代,很少人会抱怨硬盘占用率高的问题.但是到了Windows7/8.1时,硬盘占用率成为一个扰人的问题.硬盘占用率经常100%会导致系统卡.慢,而且也很伤硬 ...
- Redis工业生产应用场景
Redis应用场景 国内外三个不同领域巨头分享的Redis实战经验及使用场景 Redis的5个常见使用场景 Redis应用场景 Redis应用场景<张善友>
- Python 获取CentOS主机信息
Python 获取主机IP地址 #!/usr/bin/env python #coding:utf-8 import os ip=os.popen("ifconfig eth0|grep ' ...
- windows server 安装phpVirtualBox web服务
这是我在Windows server 2012 下的安装过程 (1) 安装virtualbox (2) 安装IIS和PHP, 参考: https://msdn.microsoft.com/zh-cn/ ...
- 又看了半天的pdf格式的js方面的书,感觉受益匪浅啊,只会一点操作的我,要学好理论
又看了半天的pdf格式的js方面的书,感觉受益匪浅啊,只会一点操作的我,要学好理论
- unity3d 调用Start 注意
在unity3d中,同一个脚本被绑定到多个物体上的时候,只有active的物体才会调用void Start () 方法, 如果物体是NO Active 的状态,则不会调用Start,Awake也不会 ...