database adapter

83
Artic les Questions | Subscribe | Testimonials Login | Signup HOME ARTICLES INTERVIEW QN'S SCRIPTS ABOUT CONTACT CONNECT User Questions | R12 User Guides | 11i User Guides | 11i Vision Instance | R12 Vision Instance | Post Article | Request Mock Interview | BPEL Database Adapter Part 1 Author Name: prudhvi E- mail: [email protected] Database Adapter is a partnerlink in BPEL which is used to interact with Database for read, write operations. Using Database Adapter we can perform the following functions. 1. Call a Stored Procedure of Function 2. Perform DML operations like insert, update, delete on a table 3. Perform SELECT operation /w EPDw ULLTEw 0 0 vpIxaUJoP15gm c /w EW HAKx/J+vB English 00884795943223 FO RID:10

Upload: shinysuresh

Post on 04-Apr-2015

257 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Database Adapter

Articl

esQuestions | Subscribe |

Testimonials

Login | Signup

     

HOME

ARTICLES

INTERVIEW QN'S

SCRIPTS

ABOUT

CONTACT

CONNECT

User Questions  |  R12 User Guides  |  11i User Guides  |  11i Vision Instance  |  R12 Vision Instance  |  Post Article  |  Request Mock Interview  | 

BPEL Database Adapter Part 1Author

Name: prudhvi E-mail: [email protected]

 

 

Database Adapter is a partnerlink in BPEL which is used to interact with

Database for read, write operations. Using Database Adapter we can perform

the following functions.

1. Call a Stored Procedure of Function

2. Perform DML operations like insert, update, delete on a table

3. Perform SELECT operation

4. Execute custom SQL Statements

/w EPDw ULLTEw MDUyNjYzMjgPZBYCZg9kFgQCAQ9kFgQCAQ8WAh4HY29udGVudAUrRGF0YWJhc2UsQWRhcHRlciw gQlBFTCxyZWFkLCB3cml0ZSw gZXhhbXBsZWQCAg8WAh8ABfQDRGF0YWJhc2UgQWRhcHRlciBpcyBhIHBhcnRuZXJsaW5rIGluIEJQRUw gd2hpY2ggaXMgdXNlZCB0byBpbnRlcmFjdCB3aXRoIERhdGFiYXNlIGZvciByZWFkLCB3cml0ZSBvcGVyYXRpb25zLiBVc2luZyBEYXRhYmFzZSBBZGFw dGVyIHdlIGNhbiBw ZXJmb3JtIHRoZSBmb2x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ibC2mQICw 97q6AICj4K52w UC/tjalw sCruvukw gCxtey1w 0CydWCtgoC24+BqgFNVf3q45iiEyw TWLe8Nw uQ/PGzFw ==

English

008847959432230710149:f24qrsxseto

FORID:10

Page 2: Database Adapter

In this Article I will explain how to create simple synchronous BPEL process

containing Database Adapter which will read the data from a table and pa

Overview:

Database Adapter is a partnerlink in BPEL which is used to interact with Database for

read, write operations. Using Database Adapter we can perform the following functions.

1.      Call a Stored Procedure of Function

2.      Perform DML operations like insert, update, delete on a table

3.      Perform SELECT operation

4.      Execute custom SQL Statements

In this Article I will explain how to create simple synchronous BPEL process containing

Database Adapter which will read the data from a table and pass the value to output

parameter.

Prerequisites:

1.      You need to establish a Database Connection in Connection Navigator before you proceed further. Refer to my previous article on how to create a Database Connection by

clicking the following link h t t p : / / w w w . a p p s f a q . c o m / A p p s / o r a c l e - a p p l i c a t i o n s / a r t i c l e s / F u s i o n - M i d d l e w a r e / S O A / B P E L / B P E L - O l i t e - D a t a b a s e - C o n n e c t i o n / i n d e x . a s p x

2.      If this is your first BPEL Process I suggest you to go through my hello world article first.

h t t p : / / w w w . a p p s f a q . c o m / A p p s / o r a c l e - a p p l i c a t i o n s / a r t i c l e s / F u s i o n - M i d d l e w a r e / S O A / B P E L / B P E L - T u t o r i a l - f o r - b e g i n n e r s - w i t h - h e l l o w o r l d - e x a m p l e / i n d e x . a s p x

Create Application:

Open JDeveloper and select Applications in the JDeveloper

Right Click on ‘Application’ and select ‘New Application’

Page 3: Database Adapter

Create Application Window opens as show below

Page 4: Database Adapter

Change the Application Name to ‘DatabaseAdapterTutorial’

Leave remaining fields with default values and click OK

 

Click Cancel not the OK button

Create Process

Page 5: Database Adapter

Right click on the DatabaseAdapterTutorial and click New Project as show below

Select ‘BPEL Process Project’  from the projects list

Page 6: Database Adapter

Click Ok

Chang the Name which is optional and change the Template to Synchronous BPEL

Process as shown below.

Page 7: Database Adapter

Click Next

Page 8: Database Adapter

Leave the default values and click Finish

DatabaseAdapterTutorial Shows up in the Applications Navigator

Page 9: Database Adapter

On the right side of the jdeveloper window select ‘Services’ in the component Palette

dropdown box.

Page 10: Database Adapter

 

Select the Database Adapter and Drag it to right side Services portion of jdeveloper main

window

Page 11: Database Adapter

Adapter Configuration Wizard screen will pop up as below

Page 12: Database Adapter

Click Next

Enter the Service Name as ‘FetchEmail’

Description field is optional

Click Next

Page 13: Database Adapter

Select the Database Connection ‘BPELOlite’ from the Connection list. This connection

varies as you create Database connections in Connection Navigator

Leave the JNDI Name with default value and click next

Page 14: Database Adapter

Select ‘Perform an Operation on a Table’ option from the list

check Only ‘SELECT’ checkbox

Page 15: Database Adapter

Click Next

Page 16: Database Adapter

Click on Import Tables button

Page 17: Database Adapter

Click on the Query button to see the list of tables available in your database

Page 18: Database Adapter

Select the Table name from the list on which you want to operate the select command

Page 19: Database Adapter

I have selected the table ERPSCHOOLS. I am listing the commands below to create the

table ERPSCHOOLS if you want to use

Now Click Ok

Page 20: Database Adapter

Click Next

Page 21: Database Adapter

Select all columns and click Next

Page 22: Database Adapter

I am not creating any relationship with this table so just click Next button

Page 23: Database Adapter

Click Next

Page 24: Database Adapter

SELECT command is shown in SQL box.  If you want to add any parameters to the query

you can add it here. You can also directly edit your SQL statement. I am changing my

SQL statement to fetch only one record.

Page 25: Database Adapter

Click Next

Page 26: Database Adapter

Click Finish

Create Partner link will pop up as shown below

Page 27: Database Adapter

Leave all fields with default values and click OK

Now your BPEL main window screen should look like the below screen

Page 28: Database Adapter

Fetch email partner link/Database Adapter will show in Service area as shown in the red

circle.

Now select ‘Process Activities’ in the Component Palette

Page 29: Database Adapter

Select and Drag the Invoke activity below the receiveInput activity

Page 30: Database Adapter

Double click the Invoke_1 activity

Page 31: Database Adapter

Change the Name to Invoke_FetchEmail

Click on the Flashlight right to Partner Link Field

Page 32: Database Adapter
Page 33: Database Adapter

Select FetchEmail and click OK

Page 34: Database Adapter

Partner Link and Operation fields are populated automatically

Click on the Create Variable fields right to both input and output Variables

Page 35: Database Adapter

Click the small red circle icon, create variable window will pop up as shown below

Click Ok

Page 36: Database Adapter

Now click on red circle icon right to output variable

Click Ok

Page 37: Database Adapter

Click Apply

Page 38: Database Adapter

If you have everything correctly you should not see the errors in the red circle show in the

above figure.

If you don’t have any errors click OK

Main screen should look like the above picture.

We have created the Invoke activity which will call Database Adapter(FetchEmail) and

Database Adapter will query the table ERPSCHOOLS and fetches email field value. Now

to catch the value fetched by Database Adapter use Assign Activity, which will transfer

the value of email field fetched by Database Adapter to replyOutput field.

Drag the Assign activity from the component palette to mainwindow below the

Invoke_FetchEmail activity.

Page 39: Database Adapter

Double click on Assign_1 activity to open the Assign properties window

Page 40: Database Adapter

Chang the name to Assign_Email and click on the second tab ‘Copy Operation’

Page 41: Database Adapter

Click Create button circled above and select ‘Copy Operation’ to open the Create Copy

Operation window as show below

Select ns2:email on the left and client:result on the right side as show below

Page 42: Database Adapter

Click OK

Page 43: Database Adapter

Click Apply to remove the errors

Page 44: Database Adapter

Click Ok

Save your project by clicking CTRL+S

DEPLOY BPEL Process

Now we are ready to deploy the process, Start your SOA Suite and deploy the process

If you are not familiar with deploy process follow the link to see how to deploy the process

After you deploy your process successfully your Apache Ant log will show like this

Page 45: Database Adapter

Run the BPEL Process

Go to your BPEL Console

h t t p : / / l o c a l h o s t : 8 8 8 8 / B P E L C o n s o l e

login in with oc4jadmin/welcome1 (default values)

Once you login to console you can see ‘DatabaseAdapterTutorial’ project in the Deployed

BPEL Processes list.

Page 46: Database Adapter

Click on DatabaseAdapterTutorial

The initiate screen will show up

Page 47: Database Adapter

Click on Post XML Message

Page 48: Database Adapter

Click on Visual Flow

Page 49: Database Adapter

Click on Assign_Email activity to see the output

Page 50: Database Adapter

The result field contains p r u d h v i @ e r p s c h o o l s . c o m which is my output.

praneeth commented on 11/19/2009 12:30:50 AM

Excellent tutorials for Bpel beginners. Thanks for providing this to us Prudhvi.

   

Hemadri commented on 11/25/2009 3:59:34 AM

Good article

   

Page 51: Database Adapter

Brindha commented on 12/2/2009 3:59:24 AM

Really Good.. Understood the concept of DB adapter now!!

   

saravanan commented on 12/22/2009 2:48:01 AM

v.good article .would requesting to post more article on the same area if u have time.

   

Jay

Shete commented on 1/1/2010 5:32:28 PM

Very good example, Thanks for your help

   

Pawan

Saini commented on 3/10/2010 9:24:31 AM

Nice article. I have a question here, If I do not put any where clause in the generated

query will it return the complete data in the table?

   

Bhushan commented on 3/25/2010 4:46:42 PM

Hi, how can I import multiple table?

   

venky commented on 5/18/2010 3:44:22 AM

In the database connection, i connect to a remote Oracle database, when i deploy and

run the process,it gives an exception saying "Could not create/access the TopLink

Session.

This session is used to connect to the datastore" and says to change the oc4j-ra.xml in

the J2EEHome directory....pls help

   

stanly commented on 5/29/2010 11:03:11 AM

Nice tutorial Prudhvi. Thanks for sharing it with us.

    1

Comments Box

Name:

Page 52: Database Adapter

Email:

Receive email on comment updated

    Copyright © 2007 www.erpschools.com

In this article I will explain how to pass parameters to the Database Adapter. This article is

continuation of our previous Database Adapter Tutorial 1.

Open previously created project in jdeveloper.

Post

Cancel

Page 53: Database Adapter

Now Double Click the ‘FetchEmail’ Database Adapter

Page 54: Database Adapter

Click the Define Adapter Service Icon

Page 55: Database Adapter

Click Next

Page 56: Database Adapter

Next

Page 57: Database Adapter

Next

Page 58: Database Adapter
Page 59: Database Adapter

Next

Page 60: Database Adapter

Next

Page 61: Database Adapter

Next

Page 62: Database Adapter

In the Parameters Section Click Add Button

Enter Parameter Name as v_id

Click Ok

In the SQL Section click Edit Button

Page 63: Database Adapter

Click Yes

Click Add

Page 64: Database Adapter

In the Second Argument select Parameter option and select v_id

Click Ok

Page 65: Database Adapter

Click Next

Page 66: Database Adapter

Click Finish

Page 67: Database Adapter

Click Apply and Ok

Save Project CTRL+S

Now Double Click Invoke_FetchEmail activity and

Select Operation as FetchEmailSelect_v_id

Page 68: Database Adapter

Click Automatically Create Input Variable button and Automatically Create Output Variable

buttons to create new variables

Click Apply and then OK

Save Project CTRL+S

Drag Assign Activity below the receiveInput and above the Invoke_FetchEmail

Page 69: Database Adapter

Double Click Assign_1 activity

Page 70: Database Adapter

Click Copy Operation tab

Page 71: Database Adapter

From Type: Variable

Client:input

To Type: Variable

ns2:v_id

Page 72: Database Adapter

Click Ok

 

Page 73: Database Adapter

Click Apply and OK

Save project CTRL+S

Double Click Assign_Email

And change the Copy Operation as per below picture

Click Ok

Save CTRL+S

Page 74: Database Adapter

Deploy the process

Page 75: Database Adapter

Select version as 1.1

Page 76: Database Adapter

Click Ok

Page 77: Database Adapter

BUILD SUCCESSFUL

Now go to h t t p : / / l o c a l h o s t : 8 8 8 8

Click BPEL Control

Page 78: Database Adapter

Click On DatabaseAdapterTutorial v 1.1

Page 79: Database Adapter

Enter the ID number as input and click submit

Page 80: Database Adapter

Output is displayed

Verify the output with Database

Page 81: Database Adapter

Pratap commented on 9/22/2009 5:24:35 PM

Hi,

Thanks for sharing the info.

How to fetch multiple records using db adapter.

Right now I have 5 to 6 columns in my query and in the output of bpel process I can view

only one column.

How can I view multiple columns and multiple records.

Thanks in Advance

Pratap

Regards,

Page 82: Database Adapter

Pratap.    

mIKE commented on 10/15/2009 12:39:37 PM

do you have an update example??    

vinodkumar commented on 8/17/2010 3:23:50 AM

HI SIR,

THANKS FOR GIVING ME THIS VALUEABLE INFORMATION..........