【发布时间】:2015-12-16 23:14:47
【问题描述】:
请知道我在数据库方面还很陌生。我能够正确安装 mySQL 并安装 java 连接器驱动程序。但是,每当我在 Eclipse 中运行程序并尝试从我创建的数据库中检索信息时,我都会收到以下消息:“需要 SSL 连接,但服务器不支持”。这是我想使用安全 SSL 连接运行的代码:
`public static void main(String[] args) {
String username = "";
String password = "";
String dbURL = "jdbc:mysql://localhost:3306/demo"
+ "?verifyServerCertificate=false"
+ "&useSSL=false"
+ "&requireSSL=false";
try{
// 1. Get a connection to database
Connection myConn = DriverManager.getConnection(dbURL, username, password);
// 2. Create a statement
Statement myStmt = myConn.createStatement();
// 3. Execute SQL query
ResultSet myRs = myStmt.executeQuery("select name from movies");
// 4. Process the result set
while(myRs.next()){
System.out.println(myRs.getString("name") );
}
}
catch(Exception exc){
exc.printStackTrace();
}`
【问题讨论】: