当我尝试与MySQL建立基于JDBC的SSL连接时,出现以下异常:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:无法打开file://home/files/_jvm/bin/keystore.jks [home]
Class.forName("com.mysql.jdbc.Driver");
Properties mysqlProperties = new Properties();
mysqlProperties.put("user", "root");
mysqlProperties.put("password", "root");
mysqlProperties.put("clientCertificateKeyStoreUrl", "file://home/files/_jvm/bin/keystore.jks");
mysqlProperties.put("clientCertificateKeyStorePassword", "mypass");
mysqlProperties.put("trustCertificateKeyStoreUrl", "file://home/files/_jvm/bin//truststore.jks");
mysqlProperties.put("trustCertificateKeyStorePassword", "mypass");
con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/db74?verifyServerCertificate=true&useSSL=true&requireSSL=true",
mysqlProperties);
System.out.println(con.getMetaData().getDatabaseProductName());
我希望通过加密连接[基于SSL / TLS的连接]获得数据库名称。