How to set up dynamic jdbc credentials using data source?
733485Jun 7 2010 — edited Jun 8 2010I am using JDeveloper 11.1.1.3 and the dynamic jdbc credentials works properly when the "Connection Type" is set to "JDBC URL".
When I switched the "Connection Type" to "JDBC DataSource", the dynamic jdbc credentials stopped working.
The problem was not with the configuration of the database source as the application able to connect to the database.
However, as the database connection was not using the proper logged-in user account, the data was not loaded correctly.
My bc4j.xcfg was changed as per the following to use "Data Source".
<AppModuleConfigBag ApplicationName="MyAppModule">
<AppModuleConfig DeployPlatform="LOCAL" ...>
<Database jbo.server.internal_connection="java:comp/env/jdbc/appDS"/>
<Custom JDBCDataSource="java:comp/env/jdbc/appDS"/>
</AppModuleConfig>
...
</AppModuleConfigBag>
I debugged the application and found both the DynamicJDBCSessionCookieFactory and DynamicJDBCEnvInfoProvider classes were run the same way before and after switching to "Data Source":
public class DynamicJDBCSessionCookieFactory extends HttpSessionCookieFactory {
public SessionCookie createSessionCookie(String name, String value,
ApplicationPool pool,
Properties properties) {
SessionCookie cookie =
super.createSessionCookie(name, value, pool, properties);
if (properties != null) {
HttpServletRequest request = (HttpServletRequest)ADFContext.getCurrent().getEnvironment().getRequest();
HttpSession session = request.getSession(false);
if (session != null) {
Hashtable env = pool.getEnvironment();
env.remove(Configuration.DB_USERNAME_PROPERTY);
env.remove(Configuration.DB_PASSWORD_PROPERTY);
EnvInfoProvider provider =
new DynamicJDBCEnvInfoProvider((String)session.getAttribute(Configuration.DB_USERNAME_PROPERTY),
(String)session.getAttribute(Configuration.DB_PASSWORD_PROPERTY));
cookie.setEnvInfoProvider(provider);
}
}
return cookie;
}
...
}
public DynamicJDBCEnvInfoProvider(String jdbcUserName,
String jdbcPassword) {
mJDBCUserName = jdbcUserName;
mJDBCPassword = jdbcPassword;
}
public Object getInfo(String info, Object connEnvironment) {
if (mJDBCUserName != null) {
((Hashtable)connEnvironment).put(Configuration.DB_USERNAME_PROPERTY,
mJDBCUserName);
}
if (mJDBCPassword != null) {
((Hashtable)connEnvironment).put(Configuration.DB_PASSWORD_PROPERTY,
mJDBCPassword);
}
return null;
}
...
Are there any configuration I missed to setup the "Dynamci JDBC Credentials" stop working with "Data Source" ?