-
2021-07-28 16:29:02更多相关内容
-
JDBC——setting useSSL=false, or set useSSL=true
2021-01-27 19:04:26You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.============= 1朱琼 男22 2王珊珊 女21 ============ 用...今天写了一段代码:出问题了,不要慌,百度,解决了,哈哈。得劲。
1 packagecn.zpoor.DBTest;2
3 importjava.sql.DriverManager;4 importjava.sql.ResultSet;5 importjava.sql.SQLException;6
7 importcom.mysql.jdbc.Connection;8 importcom.mysql.jdbc.PreparedStatement;9
10 public classStudents {11 private intid;12 privateString name;13 privateString sex;14 private intage;15 public Students(String name, String sex, intage) {16 this.id = 0;17 this.name =name;18 this.sex =sex;19 this.age =age;20 }21 public intgetId() {22 returnid;23 }24 public void setId(intid) {25 this.id =id;26 }27 publicString getName() {28 returnname;29 }30 public voidsetName(String name) {31 this.name =name;32 }33 publicString getSex() {34 returnsex;35 }36 public voidsetSex(String sex) {37 this.sex =sex;38 }39 public intgetAge() {40 returnage;41 }42 public void setAge(intage) {43 this.age =age;44 }45
46
47 private staticConnection getConn() {48 String driver = "com.mysql.jdbc.Driver";49 String url = "jdbc:mysql://localhost:3306/school";50 String username = "root";51 String password = "zhuqiong520";52 Connection conn = null;53 try{54 Class.forName(driver);//加载驱动
55 conn =(Connection) DriverManager.getConnection(url, username, password);56 } catch(ClassNotFoundException e) {57 e.printStackTrace();58 } catch(SQLException e) {59 e.printStackTrace();60 }61 returnconn;62 }63
64 private staticInteger getAll() {65 Connection conn =getConn();66 String sql = "select * from students";67 PreparedStatement pstmt;68
69 try{70 pstmt =(PreparedStatement) conn.prepareStatement(sql);71 ResultSet rs =pstmt.executeQuery();72 int col =rs.getMetaData().getColumnCount();73 System.out.println("=============");74 while(rs.next()) {75 for(int i = 1;i<=col;i++) {76 System.out.println(rs.getString(i)+"\t");77 if (i==2 && rs.getString(i).length()<8) {78 System.out.println("\t");79 }80 }81 System.out.println("");82 }83 System.out.println("============");84 } catch(SQLException e) {85 e.printStackTrace();86 }87 return null;88 }89
90 public static voidmain(String[] args) {91 Students.getAll();92 }93 }
Wed Oct 11 22:20:41 CST 2017 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.=============
1朱琼
男22
2王珊珊
女21
============
用的是java-connector-5.1.42-bin.jar
当然结果是对的,但是上面一行说的什么useSSl没有设置,百度了一下,是这样的。
冷静分析:主要是我的jar包版本过高造成的。用以前的旧版本没什么问题,而且新版本的MySQL要求是否进行ssl连接。
解决方法:这样写就可以了 String url = "jdbc:mysql://localhost:3306/school?useSSL=false";
拓展:conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/Test_db?useUnicode=true&characterEncoding=utf-8&useSSL=false","root","password");
useUnicode设置主要是设置字符编码为utf-8,也可以在eclipse中设置默认的字符编码。
原文:http://www.cnblogs.com/zpoor/p/7653455.html
-
MySQL建立SSL连接问题,设置useSSL=false显式禁用SSL,或者设置useSSL=true
2021-02-01 19:21:30You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.要求如果未设置显式选项,则默认情况下必须建立SSL连接。 ...You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
要求如果未设置显式选项,则默认情况下必须建立SSL连接。 为了与不使用SSL的现有应用程序兼容,将verifyServerCertificate属性设置为'false'。 您需要通过设置useSSL = false来显式禁用SSL,或者设置useSSL = true并为服务器证书验证提供信任库。
解决办法:
所以为了配合他们的要求,且不为我学习jdbc添加困难,我们选择禁用:
您需要通过设置useSSL = false显式禁用SSL,或者设置useSSL = true并为服务器证书验证提供信任库。
所以,在填写c3p0-config.xml配置文件时,在url一栏添加useSSL=false
jdbc:mysql://localhost:3306/test?&useSSL=false&serverTimezone=UTC
C3P0连接池配置一些参数
参数名称
参数说明
user
数据库用户名(用于连接数据库)
password
用户密码(用于连接数据库)
useUnicode
是否使用Unicode字符集,如果参数characterEncoding设置为gb2312或gbk,本参数值必须设置为true
characterEncoding
当useUnicode设置为true时,指定字符编码。比如可设置为gb2312或gbk
autoReconnect
当数据库连接异常中断时,是否自动重新连接?
autoReconnectForPools
是否使用针对数据库连接池的重连策略
failOverReadOnly
自动重连成功后,连接是否设置为只读?
maxReconnects
autoReconnect设置为true时,重试连接的次数
initialTimeout
autoReconnect设置为true时,两次重连之间的时间间隔,单位:秒
connectTimeout
和数据库服务器建立socket连接时的超时,单位:毫秒。 0表示永不超时,适用于JDK 1.4及更高版本
socketTimeout
socket操作(读写)超时,单位:毫秒。 0表示永不超时
-
mysql 建立SSL连接问题,设置useSSL=false显式禁用SSL,或者设置useSSL=true
2021-01-19 04:12:10you need either to explicitly disable ssl by setting usessl=false, or set usessl=true and provide trustsore for server certificate verification警告:不建议在未经服务器身份验证的情况下建立SSL连接。...you need either to explicitly disable ssl by setting usessl=false, or set usessl=true and provide trustsore for server certificate verification
警告:不建议在未经服务器身份验证的情况下建立SSL连接。根据MySQL 5.5.45+、5.6.26+和5.7.6+的要求,如果未设置显式选项,则默认情况下必须建立SSL连接。为了符合不使用SSL的现有应用程序,verifyServerCertificate属性设置为“false”。您需要通过设置useSSL=false显式禁用SSL,或者设置useSSL=true并为服务器证书验证提供信任存储
处理办法
第一种处理办法
jdbcUrl=jdbc:mysql://localhost:3306/zht?useUnicode=true&characterEncoding=utf-8&useSSL=false
1
1.先将mysql-connector-java的版本改到5.5.45之下
2.再将jdbcUrl改成如下
jdbcUrl=jdbc:mysql://localhost:3306/zht?useUnicode=true&characterEncoding=utf-8
1
第二种处理办法
如果你觉得更喜欢5.5.45以后的版本,那么需要将jdbc.properties里jdbcUrl换成新的:
jdbc:mysql://192.168.0.105:3306/shgb_fz?useUnicode=true&characterEncoding=UTF8&autoReconnect=true&zeroDateTimeBehavior=convertToNull
参数名称 参数说明
user 数据库用户名(用于连接数据库)
password 用户密码(用于连接数据库)
useUnicode 是否使用Unicode字符集,如果参数characterEncoding设置为gb2312或gbk,本参数值必须设置为true
characterEncoding 当useUnicode设置为true时,指定字符编码。比如可设置为gb2312或gbk
autoReconnect 当数据库连接异常中断时,是否自动重新连接?
autoReconnectForPools 是否使用针对数据库连接池的重连策略
failOverReadOnly 自动重连成功后,连接是否设置为只读?
maxReconnects autoReconnect设置为true时,重试连接的次数
initialTimeout autoReconnect设置为true时,两次重连之间的时间间隔,单位:秒
connectTimeout 和数据库服务器建立socket连接时的超时,单位:毫秒。 0表示永不超时,适用于JDK 1.4及更高版本
socketTimeout socket操作(读写)超时,单位:毫秒。 0表示永不超时
来源:oschina
链接:https://my.oschina.net/u/3795908/blog/4441035
-
报错 You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and ...
2022-05-09 21:22:46MySQL报错 You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide 在url最后添加 ?characterEncoding=utf-8&useSSL=false 例如: url: jdbc:mysql://localhost:... -
用useSSL=true或useSSL=false无法解决WARN: Establishing SSL connection without server‘s identity ...
2021-05-17 11:05:42用useSSL=true或useSSL=false无法解决WARN: Establishing SSL connection without server’s identity verification is not recommended. …报错的解决方法(自用) 问题描述: 在b站自学mybatis,明明和视频操作... -
useSSL = false 与 ture 的区别
2021-03-06 14:20:44useSSL = false 与 true 的区别 欢迎使用Markdown编辑器 你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想学习如何使用Markdown编辑器, 可以仔细阅读这篇文章,了解一下Markdown的基本语法知识。 ... -
hive连接mysql出现 useSSL=false, or set useSSL=true
2020-11-23 22:40:54关于hive连接mysql出现 WARN ...······· useSSL=false, or set useSSL=true and provide truststore for server certificate verification. 修改hive的配置文件 (第10行) : [root@hadoop102 conf]# pwd -
You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide t
2020-06-02 20:04:52Tue Jun 02 19:41:18 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 ... -
报错信息:You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true
2021-09-08 10:24:18java运行报错,报错信息:You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide tr 解决办法: 找到配置文件,***.properties或者 其他配置数据库连接的地方 将 ... -
Java项目远程连接报错“useUnicode=true&characterEncoding=UTF-8&verifyServerCertificate=false&useSSL=...
2021-08-08 20:52:24java控制台报错: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@2cc03c1 – Acquisition Attempt ...useUnicode=true&characterEncoding=UTF-8&verifyServerCertificate=false&useSSL=false -
mySql的连接useSSL=false
2022-04-21 15:52:20原文地址:mySql的连接useSSL=false 问题: web应用中连接mysql数据库时后台会出现这样的提示: Establishing SSL connection without server’s identity verification is not recommended. According to MySQL ... -
useSSL=false 连接配置详解
2021-12-12 18:31:36Establishing 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 ... -
pyspark 对于关闭mysql 的useSSL的方法&useSSL=false 无效
2022-04-21 10:58:39mysql SSL 关闭 -
数据库连接URL配置 ?useSSL=false&serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-8
2022-02-25 17:02:46参数 解释 ...useSSL=false mac电脑不使用安全连接 useUnicode=true&characterEncoding=UTF-8 https://blog.csdn.net/wangshuminjava/article/details/81478078 serverTimezone=UTC 设置时区 -
mysql数据库的useSSL=false或者useSLL=true参数设置的区别
2021-05-18 23:39:43我们在进行数据库的连接,需要配置...useSSL=false&useUnicode=true&characterEncoding=utf8 jdbc.username=root jdbc.password=123456 在这里有一个地方需要注意,MySQL在高版本需要指明是否进行SSL连接。 SS -
You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide tr
2019-07-08 20:40:22我们在使用jdbc连接mysql的时候有时候... Mon Jul 08 17:02:47 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ ... -
【javaWeb】 You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true...
2019-01-09 10:36:21WARN: 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... -
web开发中 数据库配置的useSSL=false和时区设置Timezone
2021-07-25 09:16:19几以上的版本 需要配置useSSL=true 或者useSSL=flase 解决方法: url: jdbc:mysql://localhost:3306/springcloud01(在后面加上useSSL的配置) url: jdbc:mysql://localhost:3306/springcloud01?useSSL=false MySql8... -
useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true 等一些Mysql JDBC Url参数...
2018-10-23 17:31:58要求SSL连接,useSSL=true? 默认值为“假”。 No false 3.1.0 allowUrlInLocalInfile 驱动程序在是“LOAD DATA LOCAL INFILE”语句中...