...
Log in to the management console and select Create under Data Service.
In the Create Data Service screen, enter RDBMS AccountDetailsService as the data service name.
Click Next.
When you get to the Add New Data Source screen, enter the following details:
Datasource ID : AccountDetails
Datasource type: RDBMS
Database Engine: Select MySQL
URL : jdbc:mysql://localhost:3306/trainingdbdetails as shown below.
Field Value Datasource ID AccountDetails Datasource type RDBMS Database Engine Select MySQL URL jdbc:mysql://localhost:3306/trainingdb User Name root Password (Leave this field blank) Info If you enter External instead of the Default datasource type, your datasource should be supported by an external provider class, such as
com.mysql.jdbc.jdbc2.optional.MysqlXADataSource.
You can select the External option and enter the name and value of connection properties by clicking Add Property. For example,
After an external datasource is created, it can be used as a usual datasource in queries. See the tutorial on handling distributed transactions for more information on using external datasources.Note Be sure to download the JDBC driver for MySQL from here and copy it to your
<EI_HOME>/lib
directory.If the driver class does not exist in the relevant folders when you create the datasource, you will get an exception such as 'Cannot load JDBC driver class com.mysql.jdbc.Driver'.
- Enter the URL to your MySQL database in the URL field.
- Enter the username and password to connect to your MySQL database. By default the username is root and the password is blank.
Click Save and then Next to start defining a query.
...
Step 5: Finish creating the data service
Once you have defined the operation, click Finish to complete the data service creation process. You will now be taken to the Deployed Services screen, which shows all the data services deployed on the server.
Step 6: Invoking your data service
You can try the data service you created by using the TryIt tool that is in your product by default.
- Go to the Deployed Services screen.
- Click the Try this service link for the RDBMS data service AccountDetailsService. The TryIt Tool will open with the data service.
- Select the operation you created earlier. You need to provide the account ID as an input. Enter '1'.
Click Send to see the details of the account.
Code Block <Entries xmlns="http://ws.wso2.org/dataservice"> <Entry> <AccountID>1</AccountID> <Branch>AOB</Branch> <AccountNumber>A00012</AccountNumber> <AccountType>CURRENT</AccountType> <Balance>231221</Balance> <ModifiedDate>2014-12-02+05:30</ModifiedDate> </Entry> </Entries>