Reputation: 467
I am facing a problem connecting my java application to an oracle database using oracle wallet as password store.
To isolate the problem I made a small Main class as follow:
public static void main(String[] args) {
Connection conn;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
System.setProperty("oracle.net.tns_admin", "c:\\tns");
OracleDataSource ds = new OracleDataSource();
Properties props = new Properties();
System.setProperty("oracle.net.wallet_location", "c:/wallet2");
ds.setConnectionProperties(props);
ds.setURL("jdbc:oracle:thin:/@XE2");
Provider p;
p = new OraclePKIProvider();
Security.insertProviderAt(p, 3);
conn = ds.getConnection();
} catch (SQLException ex) {
Logger.getLogger(main.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(main.class.getName()).log(Level.SEVERE, null, ex);
}
in the directory c:\tns I've the following files:
sqlnet.ora
tnsnames.ora
this is the listing for sqlnet.ora
SQLNET.AUTHENTICATION_SERVICES = (NTS)
names.directory_path = TNSNAMES
SQLNET.WALLET_OVERRIDE = TRUE
#WALLET_LOCATION = (SOURCE=(METHOD=FILE)METHOD_DATA=(DIRECTORY=c:\wallet))
WALLET_LOCATION = (SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=c:/wallet)))
that for the tnsnames
...
XE2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
In c:\wallet2 there are the following files:
cwallet.sso
ewallet.p12
the file was previously generated with orapki and there is my entry named XE2 with the correct credential. When I run the code I get the following exception
Could not open wallet. java.io.IOException: Could not open wallet. Check password
enabling the oracle trace I can see these lines:
mar 02, 2017 3:57:00 PM oracle.jdbc.driver.DatabaseError findMessage
TRACE_30: Enter: "ORA-17168", java.io.IOException: Could not open wallet. java.io.IOException: Could not open wallet. Check password
mar 02, 2017 3:57:00 PM oracle.jdbc.driver.Message11 msg
TRACE_30: 72B6CBCC Enter: "ORA-17168", java.io.IOException: Could not open wallet. java.io.IOException: Could not open wallet. Check password
mar 02, 2017 3:57:00 PM oracle.jdbc.driver.Message11 msg
TRACE_30: 72B6CBCC Exit [0.066509ms]
and
mar 02, 2017 3:57:00 PM oracle.jdbc.driver.PhysicalConnection getSecretStoreCredentials
GRAVE: Throwing SQLException: 168java.io.IOException: Could not open wallet. java.io.IOException: Could not open wallet. Check password
Anyone can help me? Thanks for reading. r.
Upvotes: 3
Views: 10627
Reputation: 19110
I think that your ewallet.p12
file is protected by password.
You need do setup the oracle.net.wallet_password
property with the password:
System.setProperty("oracle.net.wallet_password", "PASSWORD");
If the password is specified, the driver looks for the p12 file, otherwise it uses the sso file.
Upvotes: 0
Reputation: 1
SQLNET.AUTHENTICATION_SERVICES = (NTS)
That should that be TNS instead of NTS.
Upvotes: -4
Reputation: 1
This is very old topic . -TNS_ADMIN should point to the wallet location ( C:\wallet2 ) -in tnsnames.ora wallet_location is C:\wallet2 not c:/walet as you have
Upvotes: 0