Rain_sudo
2015-12-11 19:48
Fri Dec 11 18:28:21 CST 2015 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.
小美,22
看到这里就实验了一下,就是要在连接数据库中添加设置useSSL=false
即在原来的数据库名称后面添加
?useUnicode=true&characterEncoding=utf-8&useSSL=false
我就直接后面加个这个就好了?useSSL=false;
jdbc:mysql://localhost:3306/spring?useSSL=true
关键是在jdbc建立连接的时候,出于安全考虑,连接通道采用SSL,只需要加上useSSL=true的参数就好了。
当然,前面程序里面报的是warning,不加这个参数,也不会有问题。
Sun Feb 19 18:09:11 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.这个是怎么回事呢
新版本的MySQL要求是否进行ssl连接,conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/jsp_db?useUnicode=true&characterEncoding=utf-8&useSSL=false","root","123456");正解!
如果你非要不让他报warning,你改成这样就行了
String url="jdbc:mysql://localhost:3306/bbs?user=root&password=usbw&useSSL=false";
这个不是报错,我以前百度过,这个不影响你使用,你肯定用的5.1.38版本的jar所以出现这个问题,我以前用老版本的jar包没问题
我的错误是unknown database ‘jsp_db’怎么回事
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/jsp_db","root","123456");
这个地方改成conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/jsp_db?useUnicode=true&characterEncoding=utf-8&useSSL=false","root","123456");
试试,我的可以了
package com.JDBCTest;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class JDBCTest {
public static void main(String[] args){
String sql = "select * from tbl_user";
Connection conn = null;
Statement st = null;
ResultSet rs = null;
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/jsp_db","root","123456");
st = conn.createStatement();
rs = st.executeQuery(sql);
while (rs.next()) {
System.out.print(rs.getInt("id"+" "));
System.out.print(rs.getString("name"+" "));
System.out.print(rs.getString("password"+" "));
System.out.print(rs.getString("email"+" "));
}
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
rs.close();
st.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
有同样的错误。。。。。。。。
一直没在网上查到解决办法,求大神解决
我看了一眼,用的mysql数据库,我学这个的时候用的sqlserver,不过建的是java项目还是javaweb项目连接数据库的代码都差不多,写的是数据库工具类吗?
你做的是什么呢?
问题没描述清楚...
PS:网名很相似!哈哈
JDBC之 “ 对岸的女孩看过来”
99327 学习 · 856 问题
相似问题