Forum Stats

  • 3,874,065 Users
  • 2,266,670 Discussions


SEPS (wallet) seems ignored in Java stored procedure in OJVM

We are required to code Java stored procedure in DB (because needs to be called by PL/SQL) and make separate remote DB connection, and using wallet. Tried standalone Java code with using wallet is working properly. When put the same code to DB with "loadjava", publish the function in PL/SQL we tested and found it always responds with ORA-1017:

java.sql.SQLException: ORA-01017: invalid username/password; logon denied 
   at oracle.jdbc.driver.T4CTTIoer.processError( 
   at oracle.jdbc.driver.T4CTTIoer.processError( 
   at oracle.jdbc.driver.T4CTTIoer.processError(
   at oracle.jdbc.driver.T4CTTIfun.processError(
   at oracle.jdbc.driver.T4CTTIoauthenticate.processError(
   at oracle.jdbc.driver.T4CTTIfun.receive(
   at oracle.jdbc.driver.T4CTTIfun.doRPC(
   at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(
   at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(
   at oracle.jdbc.driver.T4CConnection.logon(
   at oracle.jdbc.driver.PhysicalConnection.connect(
   at oracle.jdbc.driver.T4CDriverExtension.getConnection(
   at oracle.jdbc.driver.OracleDriver.connect(
   at java.sql.DriverManager.getConnection(
   at java.sql.DriverManager.getConnection(
   at dbconn.pass_string(dbconn:33)

When modified the code to feed set user and password in connection properties this Java stored procedure works as expected. The same code running "outside" OJVM is okay, the Java code has the required system properties set, and connection is using TNS alias, like:

Connection con=DriverManager.getConnection("jdbc:oracle:thin:/@JUAT")

But it seems it only recognizes the "" property (as it found with the TNS alias) but not the wallet_location property when running in the OJVM.

This issue we tested happens in 19c (19.8) and also 12c (12.1), so would it be OJVM does not work with SPES by design (but I see no doc or info saying so)? Or anything missing in Java code certain properties need to be set to make it work?

I know when using SPES in Java we need to include "oraclepki.jar" in classpath, while in OJVM we do not have this option, would it be related?




  • Ghui-Oracle
    Ghui-Oracle Member Posts: 3 Employee

    Here is the simple Java code we used to test. Thanks.

    import java.text.SimpleDateFormat;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.*;
    import java.util.*;
    public class dbconn {
    public static String pass_string(){
     try {
       //Properties props = new Properties();
       // Environment specific information: TNS_ADMIN, wallet location
       // Also the TNS alias was created as wallet credential (e.g. JUAT)
       //Connection con=DriverManager.getConnection("jdbc:oracle:thin:@JUAT", props);
       Connection con=DriverManager.getConnection("jdbc:oracle:thin:/@JUAT");
    PreparedStatement pstmt = con.prepareStatement("select 'Connected DB: '||name from v$database");
    ResultSet rs = pstmt.executeQuery();
    String col1 = new String();
    while (
    col1 = rs.getString(1);
    if (con != null) {
      return col1;
    } else {
      return new String("Failed to get connection object");
    }}catch(SQLException e) {
         StringWriter sw = new StringWriter();
         PrintWriter pw = new PrintWriter(sw);
         String stacktrace = sw.toString();
    return new String("EXCEPTION (SQLException): " + stacktrace + "\n");
    } catch(Exception e) {
    return new String("EXCEPTION (Exception): " + e.getMessage() + "\n");
    public static void main(String[] args) {
      String rs = pass_string();
  • User_N3N2V
    User_N3N2V Member Posts: 2 Green Ribbon

    One quick question , Will get a different cwallet.sso file each database or we can use the same file for all databases. 

    we have around 25 db's How do we load cwallet.sso file before getting the connection ....

    Please give any suggestions ..

    System.setProperty("", "(SOURCE=(METHOD=file)(METHOD_DATA=(DIRECTORY=C:/Users/X/Desktop/SSL AWS/Oracle SSL/wallets)))");

    If we keep around 10 files in the same location... Will oralce driver will load automatically respective DB file....

    acwallet.sso , bwallet.sso, cwallet.sso etc..