[英]Java JDBC and Oracle Wallet Connection
How to use oracle wallet 如何使用Oracle钱包
Using this as reference. 以此为参考。 I am still unable to connect to Oracle Wallet. 我仍然无法连接到Oracle Wallet。 Sample code below. 下面的示例代码。
Errors 失误
--
java.sql.SQLException: encountered a problem with the Secret Store. Check the wallet location for the presence of an open wallet (cwallet.sso) and ensure that this wallet contains the correct credentials using the mkstore utility: java.io.IOException: oracle.security.crypto.cert.PKCS12.getAuthSafesAsList()Ljava/util/ArrayList;
at oracle.jdbc.driver.PhysicalConnection.getSecretStoreCredentials(PhysicalConnection.java:1314)
at oracle.jdbc.driver.PhysicalConnection.parseUrl(PhysicalConnection.java:1198)
at oracle.jdbc.driver.PhysicalConnection.readConnectionProperties(PhysicalConnection.java:982)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:646)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:428)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:38)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:691)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
-- -
public static void main (String [] args) {
System.out.println("-------- Oracle JDBC Connection Testing ------");
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (ClassNotFoundException e) {
System.out.println("Where is your Oracle JDBC Driver?");
e.printStackTrace();
return;
}
System.out.println("Oracle JDBC Driver Registered!");
Connection connection = null;
determineAndSetTnsHome();
try {
connection = DriverManager.getConnection(
"jdbc:oracle:thin:/@xxx");
} catch (SQLException e) {
System.out.println("Connection Failed! Check output console");
e.printStackTrace();
return;
}
if (connection != null) {
System.out.println("You made it, take control your database now!");
} else {
System.out.println("Failed to make connection!");
}
}
private static void determineAndSetTnsHome() {
String tnsAdmin = System.getenv("TNS_ADMIN");
if (tnsAdmin == null) {
String oracleHome = System.getenv("ORACLE_HOME");
if (oracleHome == null) {
return; //failed to find any useful env variables
}
tnsAdmin = oracleHome + File.separatorChar + "network" + File.separatorChar + "admin";
}
System.setProperty("oracle.net.tns_admin", tnsAdmin);
}
-- -
Confirmed that wallet is setup. 确认钱包已设置。 - Doing sqlplus $xxx connects fine. -执行sqlplus $ xxx可以正常连接。
Thanks in advance. 提前致谢。
Your wallet may be installed and configured correctly, but that does not mean the wallet is currently open. 您的钱包可能已正确安装和配置,但这并不意味着该钱包当前处于打开状态。 Anytime the database is restarted, the wallet needs to be opened. 每当数据库重新启动时,都需要打开钱包。
Run a sample query against a known table in your schema in SQL*Plus (connecting is not enough) 在SQL * Plus中对架构中的已知表运行示例查询(连接不够)
If the wallet is not open you will get the following error: 如果钱包未打开,则会出现以下错误:
ORA-28365: wallet is not open ORA-28365:钱包未打开
This query should give you the status of the wallet: 此查询应为您提供钱包的状态:
select wrl_type wallet,status,wrl_parameter wallet_location from v$encryption_wallet;
In order to open a wallet, run the following command, replacing "myPassword" with the password you chose: 为了打开钱包,请运行以下命令,将“ myPassword”替换为您选择的密码:
ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY "myPassword";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.