读取用户名和密码的Java代码段,使用oracle钱包加密

时间:2019-07-14 03:20:03

标签: java jdbc oracle11g oracle-wallet

数据库用户名和密码使用shell变量存储。 echo $ DATABASE将以以下形式返回用户名,密码和数据库主机。 “用户/密码@dbhost”。由于使用oracle钱包对用户名和密码进行了加密,因此echo $ DATABASE将返回“ / @ dbhost”。 如何使用Java代码读取用户名和密码?按照我尝试的方式,但是我得到的用户名和密码为NULL。

String db_env = System.getenv("DATABASE").split("@")[0];

例外

2019-07-13 19:17:23 ERROR DBManager:130 - SQLException occurred in getConnection due to:
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: Could not open wallet. java.io.IOException: Could not open wallet. Check password
        at oracle.jdbc.driver.PhysicalConnection.getSecretStoreCredentials(PhysicalConnection.java:3054)
        at oracle.jdbc.driver.PhysicalConnection.parseUrl(PhysicalConnection.java:2803)
        at oracle.jdbc.driver.PhysicalConnection.readConnectionProperties(PhysicalConnection.java:2341)
        at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:533)
        at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:257)
        at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
        at oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSource.java:280)
        at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:207)
        at

0 个答案:

没有答案