一 、 数据库连接报错:
报错信息如下:
Fri May 06 19:56:07 CST 2016 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.
此时的数据库连接如下:
public Connection getCon() {
try {
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://127.0.0.1/medicalsystem?useUnicode=true&characterEncoding=utf-8";
String user = "root";
String password = "123456";
Connection conn = DriverManager.getConnection(url, user, password);
return conn;
} catch (Exception e) {
e.printStackTrace();
return null;
}
调试:
这是数据库连接的问题,虽然以上的数据库连接没有问题,但有可能某个程序就是不能运行,那么这样的话,根据报错提示,设置useSSL=false就可以了。
s
String url = "jdbc:mysql://127.0.0.1/medicalsystem?useUnicode=true&characterEncoding=utf-8&useSSL=false";
二 、Date型在接受参数时,可以直接定义成String型,但是在存入数据库中时要将空的字符串设置成null,否则无法存入数据库中。