[Download] | [Documentation Home] | [Release Note]

Data Source Support

Data Services Server provide support for the following data sources.

Data Source support for RDBMS

This section explains how a Data Service can be created using a relational database table as a datasource.

Copying the JDBC Driver

As the first step to create the data service for RDBMS you should copy the relevant JDBC driver into CARBON_HOME/repository/components/lib directory. (e.g:- cp mysql-connector-java-5.XX-bin.jar /home/user/wso2ds/wso2-dataservices-XX/repository/components/lib).

There are three ways to create a data service using a relational database.


Steps to create a data service for relational database

Let's use the graphical wizard to create the data service for RDBMS. To start the wizard click on 'Create' link on your left hand menu. (Figure 1)



DS

Figure 1: Create data service for relational database



In the first screen that appears, enter a name for your Data Service('DataServiceSample1').(Figure 2)



DS

Figure 2: Create data service


Enter data source Id and select 'RDBMS' as 'Data Source' type.Enter values to be used to connect to database.


DS

Figure 3: Configure Data Source

To find more details about data source configuration parameters refer to Advanced Data Source Properties in RDBMS Data Sources.


Enter query details using which values will be extracted and specify how SQL response is mapped to output XML.


DS

Figure 4: Configure Query Information


Following query needs two parameters to be supplied for execution. Input Mapping section is used to specify input parameters.


DS

Figure 5: Input parameters


Once you add a query, it will be listed as follows.


DS

Figure 6: View query


Create an operation and select a query to be executed when this operation is called.


DS

Figure 7: Add operation


When query accepts parameters, there is an additional step. Following screen shows it.


DS

Figure 8: Add operation with input parameters


Existing operations will be listed as follows.


DS

Figure 9: View operations


Click 'Finish' button to complete the wizard.


Deployed Services will be listed as follows.


DS

Figure 10: Deployed services


Following statistics are available for a service. Options mentioned in lower part of the screen can be applied to a service.


DS

Figure 11: Service statistics


Click on 'Try it' link and you will be directed to a screen similar to following.


DS

Figure 12: Invoke service using Try-it


This is how Try-it shows results after service invocation.


DS

Figure 13: Service invocation


If there are parameters, Try it allows you to enter them as well.


DS

Figure 14: Service invocation-with parameters


WSDL for the service can be viewed by clicking 'WSDL' link.


DS

Figure 15: WSDL

RDBMS data source

For the RDBMS data source, select the data source type as 'RDBMS' after naming the data source. Enter values to be used to connect to the database.


DS

Figure 16: Creating the data source for RDBMS


Carbon Data Source

For the Carbon data sources, you have to create the carbon data source first.

To create the carbon data source click on the Data Sources menu item under the configuration.


DS

Figure 17: Create Carbon Data Source menu


Click on 'Add Data Source' link in Data Sources page which will direct you to a page where you can enter the details for the data source.

As you can see in the following data source creation UI, first you need to select the 'Data Source Type'.


DS

Figure 18: Selecting Data Source Type


There are two types of Data Sources available. The default Data Source Type is 'RDBMS'. 'Custom' is the other Data Source Type.

Carbon Data Sources - RDBMS

When you select 'RDBMS' as the Data Source Type, you can create RDBMS Data Sources through the UI.

You can select a datasource provider from the highlighted combo box. For the 'default' Data Source Provider, given connection properties Driver, URL, User Name and Password need to be entered.


DS

Figure 18: Creating a RDBMS Carbon Data Source


If you need to add a data source supported by an External Datasource Provider class such as com.mysql.jdbc.jdbc2.optional.MysqlXADataSource, select 'external' as the Data Source Provider. Then enter the name and value of connection properties by clicking 'Add Property'. Given below is an example data source of External Datasource Provider with eneterd values.


DS

Figure 19: Creating the Carbon Data Source of External Data Source Provider

After entering the details you can test the connection by click on 'Test Connection' button on bottom of the page. Then click 'Add' to save the data source.


Once you have created the carbon data source, you can use it inside the data service. Select the 'Carbon Data Source' as the type of the data source in Add data source page in the data services wizard. Select the carbon data source name which you have created from the drop down list.


DS

Figure 20: Creating the data source for Carbon Data Source


Expose as a JNDI Data source

The adding data source can be exposed as a JNDI Data Source as well. Expand 'Expose as a JNDI data source' and enter the required values. If the data source will be using Data Source Factory, click on the checkbox 'Use Data Source Factory' and define the JNDI properties. Given below is an example JNDI configuration.


DS

Figure 21: Expose as a JNDI Data source


When creating the data service select the data source type as 'JNDI' and enter the values to be used to connect to the previously created JNDI enabled data source.


DS

Figure 22: Creating the data source for JNDI


Defining Data Source Configuration Parameters

By expanding the 'Data Source Configuration Parameters' you can set the jdbc-pool properties for the data source.


DS

Figure 23: Expanding Data Source Configuration Parameters


Data Source Configuration Parameters with default values is showing below.


DS

Figure 24: Data Source Configuration Parameters


Carbon Data Sources - Custom

When you select 'Custom' as the Data Source Type, you can create supported Custom Data Sources as follows.

When you are creating a Custom Data Source, the 'Actual Type' of the Custom Data Source must be entered to 'Custom Data Source Type' field. Following shows creating a 'DS_CUSTOM' type Data Source. Then you can enter the Configuration to the XML editor and 'Save'.


DS

Figure 18: Creating a Custom Carbon Data Source


You can even create RDBMS data source using the editor by entering 'RDBMS' as the 'Custom Data Source Type'.