Developers building applications to be deployed in WebCenter Spaces / Portal, WebCenter Sites will need access to the database server. There are two options to achieve this.
Option A: Create a user/password in the database and pass it to the developer team.
This option has the following dis-advantages.
- The username/password is hardcoded in the Application. So in future if there is a change in username/password, the change has to be made in the Application.
- Giving direct access to the database is not a secure option, and will compromise Database Security.
To overcome this an alternate method generally used is,
Option B: Create a Data Source in the Weblogic Server and grant access to this data source to the applications deployed to the WebCenter Spaces/Portal servers.
This option has the following advantages.
- The application only references the data source name. All applications running on the server can use the same Data Source to securely access the database.
- Any change in permissions, passwords etc., can be done centrally at the Weblogic Server Console by modifying the Data Source configuration, and the applications can remain unaffected.
- This also ensures that a secure access to the Database is provided.
- Moving WAR files from Development Environment to UAT and then to Production Environment can be done seamlessly without changing any application code. (To achieve this, a Data Source with the “same name” should be created in all (DEV, UAT, Production) environments.
Now, Let’s see how to create a “Data Source” in the Weblogic server.
Login to WeblogicServer Console and select“DataSources” from the menu on the left (under “Domain Structure” tab “Services” menu). The screen on the right displays the list of Data Sources created. Click on the NEW button at the top (as shown in the below screen), to create a new Data Source.
After clicking new button, select “GenericDatasource” from ListPopup then Specify the name for Data source,JNDI Nameand Database type. In the screenshot below, we have used the following details.
Name of Data Source: Sample
JNDI Name: jdbc/testDS >> ADF Expects ALL JNDI names used by it to end with the string DS.
Database type: Oracle (We have chosen “Oracle” here. But you could choose the name of the respective database used in your setup).
then click NEXT to continue…….
This screen prompts us to enter the details for the Database connection (Oracle) chosen in the previous screen.
Database Name: The Database name given here is OWCSDB. You can replace it with the name of your database.
HostName: – <IP-address> or hostname
Port: -The default port for Oracle is 1521. This might be different for other databases.
Click on “NEXT” button. The next screen has an option to test the configuration details entered for the Database Connection.
Click on “Test Configuration” button to test the Database connection. If the Connection details entered in the previous screen are valid, and connection to database is established successfully, a success message “Connection test Succeeded” is displayed.
If there are errors, an error message is displayed. Click on “Back” button to go to the previous screen and re-enter the Database Connection Configuration details.
Once Connection test is successful, click on NEXT button to proceed.
For e.g., if the server “WC_Spaces” is selected, the Data Source is deployed to this server and all applications running on this server can access the database using the “Data Source” created. Multiple servers can be selected as target servers.
The application developers need only know the Data Source Name to be included in their application, thus providing a secure access to the database.