使用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 ...
随机推荐
- 【Mysql】Mysql修改Root密码
1.用命令编辑/etc/my.cnf配置文件,即:vim /etc/my.cnf 或者 vi /etc/my.cnf 或者 nano /etc/my.cnf 2.在[mysqld]下添加skip-gr ...
- Unity Package Manager Error的解决方案
问题来源 启动Unity时显示 fail to start Unity Package Manager,软件环境为 Unity 2017.3.0f3. 解决方案 根据网上所给的方案,我选择添加环境变量 ...
- Assets/FollowDestination.cs(6,13): error CS0246: The type or namespace name `NavMeshAgent' could not be found. Are you missing `UnityEngine.AI' using directive?的解决方案
问题的出现与描述 在Unity中创建一个NPC,使它一直跟踪一个目标Destination,C#脚本代码如下,错误信息描述如下 using System.Collections; using Syst ...
- android中清空一个表---类似truncate table 表名 这样的功能 android sqlite 清空数据库的某个表
public void clearFeedTable(){ String sql = "DELETE FROM " + FEED_TABLE_NAME +";" ...
- UIStatusBarStyle PreferredStatusBarStyle does not work on iOS 7
Q: In my iPhone application built with Xcode 5 for iOS 7 I set UIViewControllerBasedStatusBarAppeara ...
- POI-PPT官方文档
注意 请注意,XSLF仍然处于早期开发阶段,并且将来会在发行版中发生不兼容的更改. 特征索引 创建新的演示文稿 阅读现有演示文稿 使用预定义的布局创建幻灯片 删除幻灯片 重新订购幻灯片 更改幻灯片大小 ...
- JS性能细节学习初步总结
1,声明变量要赋初值2,尽量避免声明全局变量,可以减少与系统的重名3,当编写大量js代码时,难免会遇到命名冲突,这是可以通过模拟命名空间方式 来避免冲突4,尽量避免使用全局变量,搜索全局变量是 ...
- js Object.prototype.toString.call()
Object.prototype.toString.call(obj)使用方法以及原理 这几天看vue-router的源码 发现了Object.prototype.toString.call()这 ...
- VC++ 内存泄露与检测的一种方法
本文介绍,当VC++或者MFC程序,出现内存泄露时,如何快速定位的方法,这种方法有一定的局限性,在注意事项中会给出的. MFC程序 当MFC程序出现内存泄露时,退出程序时的VS调试输出 ...
- Android学习之——如何将GridView内嵌在ScrollView中
最近在做一个项目,有一个需求是在ScrollView中内嵌一个GridView. 刚开始,我是以为能直接内嵌在里面: <ScrollView android:layout_width=" ...