This article focus on showing how WSO2 ESB DB Report mediator can be configured with a carbon data source. Using this DB Report mediator WSO2 ESB will be able to execute Insert statements to databases. The reverse operation of this is done by DB Lookup mediator, which can query data in a database. After fixing a bug in this mediator, gui has changed for adding a carbon data source in latest WSO2 ESB 4.6.0.
Adding a data source
In here I’m going to use mysql as the database. Therefore first you need to setup mysql server (in Linux:XAMPP or in windows: WAMP, but free to use your own too). Then you need to get the jdbc-connector and put it in to wso2esb-4.5.1/repository/components/lib folder. You have to create a database and a table in mysql (in there I created ‘test’ database and ‘aa’ table inside it). Now you have done background setup. Next is to start WSO2 ESB.
Connecting to data source
In ESB web UI , goto Configure -> Data Sources -> Add Data Source. Then you have to point your database as shown in the image below. It is recommended to give JNDI name same to the Name of DB.
Adding DB Report Mediator
Go to the Main -> Sequences and edit mode of relevant sequence and add the DB Report mediator to appropriate place. In edit section showing below, select Data Source -> Carbon Data Source and select the name you gave from the list.
Then you can add the insertion statements according to the database table you made.
1. DB Report Mediator guide: http://docs.wso2.org/wiki/display/ESB451/Sample+361%3A+Introduction+to+dbreport+Mediator
2. For DB Lookup Mediator: http://docs.wso2.org/wiki/display/ESB451/Sample+360%3A+Introduction+to+dblookup+Mediator