This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Custom Datasources
A datasource is a connection set up to a storage of data, such as a database or a data file, from a server. You can create a custom datasource as follows.
- Log in to the product's management console and select Datasources sub menu from the Configure menu.
- Click Add Datasource. Â
- The New Datasource page opens. Select Custom as the datasource type, provide a unique name, a description and configure the rest of the fields using the information below:
- Custom Datasource Type : See below  Â
- Configuration : XML configuration of the datasource
Custom datasource type
The actual type of the custom datasource can be either DS_CUSTOM_TABULAR
 or DS_CUSTOM_QUERY
. There are two options cover most of the common business use cases. Â
Custom tabular datasources Â
Tabular datasources are used to connect to a source that represents its data using tables, where a set of named tables contains data rows that can be queried later. Tabular datasources are implemented using the interface org.wso2.carbon.dataservices.core.custom.datasource.TabularDataBasedDS
. See InMemoryDataSourceÂ
for a sample implementation of tabular custom datasources.
A tabular datasource is typically associated with an SQL data services query. This is done by internally using our own SQL parser to execute SQL against the custom datasource. See InMemoryDSSample
 for a sample implementation.
An example configuration of a custom datasource of type DS_CUSTOM_TABULAR
 is shown below:
Custom query datasources Â
Custom query datasources are used to connect to a source of non-tabular data that has query expression support. Even if the target data source does not have a query expression format, you can create your own and add it. This type of a datasource supports any NoSQL source of data.
Custom query datasources are implemented using the interface org.wso2.carbon.dataservices.core.custom.datasource.CustomQueryBasedDS
. See EchoDataSource
 for a sample implementation. See InMemoryDSSample
 for a sample data service descriptor with custom query datasources. Â
In the init
 methods of all custom datasources, user-specified properties are parsed to initialize the datasources accordingly. In addition, a property named __DATASOURCE_ID__
, which contains a UUID to uniquely identify the current datasource, is passed. Custom datasource authors use this property to identify the datasources. For example, in situations where datasource instances communicate within a server cluster for data synchronization.