经过昨天的研究,我发现解决方案是使用Oracle Proxy Authentication。此解决方案不属于 JDBC 规范。但是,Oracle 提供了一个钩子来实现这样的解决方案。打开代理连接如下所示:
import oracle.jdbc.OracleConnection;
//Declare variables
String url = "...";
String username = "...";
String password = "...";
//Create the Connection
Connection conn = DriverManager.getConnection(url, username, password);
//Set the proxy properties
java.util.Properties prop = new java.util.Properties();
prop.put(OracleConnection.PROXY_USER_NAME, "BILL");
prop.put(OracleConnection.PROXY_USER_PASSWORD, "password");
//Cast the Connection to an OracleConnection and create the proxy session
((OracleConnection)conn).openProxySession(OracleConnection.PROXYTYPE_USER_NAME, prop);
/* The Connection credentials have now been changed */
如果还有其他与此相关的细微差别,我不会感到惊讶,但这是一个好的开始。谢谢大家的帮助!