我正在尝试使用TCPS连接连接到AWS的Oracle RDS服务器,下面是我用来连接的代码片段
try{
OracleConnectionPoolDataSource ds = null;
ds = new OracleConnectionPoolDataSource();
Properties keyStoreProp = new Properties();
keyStoreProp.put("javax.net.ssl.trustStore", "./clientkeystore.jks");
keyStoreProp.put("javax.net.ssl.trustStoreType", "JKS");
keyStoreProp.put("javax.net.ssl.trustStorePassword", "keyStorePasssword");
ds.setConnectionProperties(keyStoreProp);
Properties cacheConProp = new Properties();
cacheConProp.setProperty("MinLimit", "25");
cacheConProp.setProperty("MaxLimit", "5");
cacheConProp.setProperty("InitialLimit", "3");
cacheConProp.setProperty("InactivityTimeout", "1800");
cacheConProp.setProperty("AbandonedConnectionTimeout", "900");
cacheConProp.setProperty("PropertyCheckInterval", "60");
cacheConProp.setProperty("ValidateConnection", "true");
cacheConProp.setProperty("ConnectionWaitTimeout", "120");
ds.setConnectionProperties(cacheConProp);
ds.setDatabaseName(dbName);
ds.setUser(dataUserName);
ds.setPassword(dataPassword);
ds.setURL(tcpsConnectionUrl);
ds.setNetworkProtocol("TCPS");
if (ds.getConnection() != null) {
LOG.info("CONNECTION_SUCCESSFUL");
} else {
LOG.error("CONNECTION_FAILED");
}
} catch (SQLException e) {
LOG.error("CONNECTION_FAILED";
e.printStackTrace();
}
并且我已经按照https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.Oracle.Options.SSL.html#Appendix.Oracle.Options.SSL.TLS doc文件中提到的“在JDBC上设置SSL连接”中的步骤创建了clientkeystore.jks文件,但是出现了Connection reset问题。
任何人都可以帮我解决这个问题。
你为什么使用OracleConnectionPoolDataSource?您可以使用OracleDataSource并查看DataSourceForJKS.java示例以供参考。