This is call Dynamic JDBC.
In this url you can see how to apply this dynamic JDBC, but in my post I will simplify this url by creating a sample ADF application and go step by step for how to apply dynamic JDBC to this ADF application.
I use JDeveloper 188.8.131.52.0.
Note: From Step1 to Step5 it just steps for creating a simple ADF application. Applying the Dynamic JDBC to this simple application is starting from Step6.
Create a simple ADF Application connect to "hr" database, this application will contains only 1 ViewObject (Employees) and will contains 2 jspx pages (login.jspx and emp.jspx)
From faces-config.xml --> Navigation Rules define outcome to the two jspx pages.
Run login.jspx page.
Now we have created a simple ADF application and we will now apply dynamic jdbc to this application.
Open AppModule and set "Connection Type" to JDBC URL for both AppModuleShared and AppModuleLocal
In the login button action we will store username/password it in session.
The login button action will be:
Create new Filter (DynamicJDBCBindingFilter.java) extends ADFBindingFilter.
Create Class (DynamicJDBCEnvInfoProvider) as
Create Class (DynamicJDBCHttpSessionCookieImpl) as
Create Class (DynamicJDBCSessionCookieFactory) as
In web.xml update adfBindings and make it point to DynamicJDBCBindingFilter
then add filter mapping to adfBindings filter
In AppModule update jbo.ampool.sessioncookiefactoryclass in AppModuleLocal and AppModuleShare to point to DynamicJDBCSessionCookieFactory
Now run login.jspx and login with database username/password = hr/hr you will successfully login and get the data
Logout then login again with wrong password as hr/hr1 you will get "Invalid username/password".
You can download the sample application from here