Friday, October 26, 2018

SOA: Create DB Connection with JDBC and JNDI

SOA: Create DB Connection with JDBC and JNDI

SOA Applications communicate with Database using DB Adapter. When SOA composites are deployed in weblogic server, they require Outbound connection pool to communicate with Database. A JDBC Data Source with Database connection details should be associated to connection pool. JNDI Name used for creating connection pool should match the value entered for database connection when building application using JDeveloper.

1.  Create JDBC Data Source: 
Navigate to Services -> Data Sources
SOA DB Connection JDBC JNDI

Click New button and select Generic Data Source to create a new JDBC Data Source as shown in above screen shot
Enter following details:
Data Source Name:  XEDB
JNDI name to refer Data Source: jdbc/XEDB
Database Type: Oracle
SOA DB Connection JDBC JNDI 2
Click Next and proceed further
Select the type Database driver to use to connect to Database and click Next.
SOA DB Connection JDBC JNDI 3
Enter Database login and host connection details on next screen
i.      Database Name: <sid or service name of Database>
ii.      Host name: <Database Host Name>
iii.      Port: <Database port number>
iv.      Database user name
v.      Password
vi.      Confirm Password.
Note: Some of these values can be obtained from tnsnames.ora file from Oracle client directory.
SOA DB Connection JDBC JNDI 4
Click Next to move on and
Click Test Configuration button to validate the connection details provided.
Connection details will be validated and successful message will be displayed as below.
SOA DB Connection JDBC JNDI 5

Click Finish button. JDBC Data Source with XEDB will be successfully created.
2.  Create Outbound Connection Pool for DB Adapter:
a.  Click Deployments link in Domain Structure present in left hand side in console window.
b.  In Summary of Deployments window, Select DBAdapter.
c.  DBAdapter settings page will be displayed.
SOA DB Connection JDBC JNDI 6
d. Click Configuration tab in DBAdapter setting and select Outbound Connection Pools tab to display list of Outbound connection pools.
SOA DB Connection JDBC JNDI 7
e. Click New button to create Outbound Connection Pool.
f. In Create a New Outbound Connection window, select default connection group “javax.resource.cci.ConnectionFactory” and click Next button.
SOA DB Connection JDBC JNDI 8
g. Enter JNDI Name, which will be used in JDeveloper to create Database server connection for DB Adapter.
JNDI Name used should match the value entered for database connection when building application using JDeveloper.
Convention followed for DB Adapter JNDI Name is “eis/DB/XEDB”, where, XEDB refers to my XE Database.
Similarly for Apps Adapter, JNDI Name starts with “eis/Apps/” like eis/Apps/AppsDB.
SOA DB Connection JDBC JNDI 9
Click Finish.

3.  Configure JDBC data source with Outbound Connection pool:
a. Select the newly created Outbound connection pool by selecting JNDI names from the list.
SOA DB Connection JDBC JNDI 10
b. In the settings window, click Properties tab.
c. For property name “xADataSourceName”, update the property value with JDBC data source JNDI name which we created in section 1 i.e. “jdbc/XEDB” and click save button.
Note: To change property value, use ENTER key after entering value and click save button.
SOA DB Connection JDBC JNDI 11

4.   Update Deployment Plan:
a. Go to main Deployments page, update DBAdapter by click Update button.
b. Select Redeploy this application and confirm the deployment plan location.
c. Click Finish button.
SOA DB Connection JDBC JNDI 12
5.   Restart the SOA server to use the newly created outbound connection pool JNDI Name “eis/DB/XEDB”.

No comments:

Post a Comment

SQL Important Queries

  How to delete rows with no where clause The following example deletes  all rows  from the  Person.Person  the table in the AdventureWork...