JDBC使用SSL连接到Oracle数据库 [英] JDBC connect to Oracle database with SSL
本文介绍了JDBC使用SSL连接到Oracle数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经配置了标准数据库连接,我连接到了Oracle数据库. 数据库将配置为使用SSL,这意味着我需要指定服务器证书才能进行连接.
I've configured a standard database connection, I connect to an Oracle database. The database will be configured to use SSL, this means that I'll need to specify the server certificate in order to connect.
SSL本身具有 SSL_CLIENT_AUTHENTICATION = FALSE ,并配置了Oracle Wallet.
The SSL itself is with SSL_CLIENT_AUTHENTICATION=FALSE and configured a Oracle Wallet.
可以使用JDBC完成吗?
Can it be done using JDBC?
这是我当前的代码:
Class.forName("oracle.jdbc.OracleDriver");
connection = DriverManager.getConnection("jdbc:oracle:thin:@192.168.200.96:1521:NNVSDB", "VSU22","VSU22");
推荐答案
您可以在此处找到包含一些文档的pdf文件: 使用Oracle JDBC的SSL ,您在第11页和第12页有一些代码示例:
You can find a pdf with some documentation here : SSL With Oracle JDBC, you have some code example page 11 and 12:
String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=servername)(PORT=2484))(CONNECT_DATA=(SERVICE_NAME=servicename)))");
Properties props = new Properties();
props.setProperty("user", "scott");
props.setProperty("password", "tiger");
props.setProperty("javax.net.ssl.trustStore",
"/truststore/ewallet.p12");
props.setProperty("javax.net.ssl.trustStoreType","PKCS12");
props.setProperty("javax.net.ssl.trustStorePassword","welcome123");
Connection conn = DriverManager.getConnection(url, props);
这篇关于JDBC使用SSL连接到Oracle数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文