The steps below explain how to create an RDBMS or custom data source using the Configure menu of the management console. You can also create a data source at the time a data service is created.
If you select the Data Source Type as RDBMS, the following screen appears.
This is the default RDBMS data source configuration provided by WSO2. Each field is explained below:
The meaning of many fields is similar to the
DBCPconfiguration guide. For more information, see http://commons.apache.org/dbcp/configuration.html.
There are two types of data source providers. You can use the default provider or link an external provider. For the default data source provider, given connection properties Driver, URL, User Name and Password need to be entered as follows:
If you need to add a data source supported by an external provider class such as
com.mysql.jdbc.jdbc2.optional.MysqlXADataSource, select the
external option and enter the name and value of connection properties. Given below is an example data source of external data source provider with entered values.
Java Naming and Directory Interface (JNDI) is a Java application programming interface (API) providing naming and directory functionality for Java software clients to discover and look up data and objects via a name. It helps decouple object creation from the object look-up. When you have registered a data source with JNDI, others can discover it through a JNDI look-up and use it.
To expose a data source as a JNDI data source, select the Expose as a JNDI Data Source.
If you select the Data Source Type as Custom, the following screen appears.
The actual type of the custom data source can be either
DS_CUSTOM_QUERY. There are two options cover most of the common business use cases.
Custom tabular data sources
Tabular data sources are used when there is a data source which represents its data using tables, where a set of named tables contains data rows that can be queried later.
To implement tabular data sources, the interface
org.wso2.carbon.dataservices.core.custom.datasource.TabularDataBasedDS is used. A sample implementation of tabular custom data source can be found at
A tabular data source 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 data source. A sample data service descriptor on how this is done can be found at
InMemoryDSSample . Also, this is supported in Carbon data sources, with the data source reader implementation
org.wso2.carbon.dataservices.core.custom.datasource.CustomTabularDataSourceReader. A sample Carbon data source configuration file can be found at
Custom query data sources
Custom query based data sources are created when there is a data source which has some form of a query expression support.
To implement , the interface
org.wso2.carbon.dataservices.core.custom.datasource.CustomQueryBasedDS is used. Any non-tabular data source can be created using the query-based approach. Even if the target data source does not have a query expression format, users can create their own and it. For example, any NoSQL type data source can be supported using this type of a data source.
A sample implementation of a query-based custom data source can be seen at
EchoDataSource . A sample data service descriptor with custom query data sources can be found in action in
InMemoryDSSample . This is supported in Carbon data sources, with the data source reader implementation
org.wso2.carbon.dataservices.core.custom.datasource.CustomQueryDataSourceReader. A sample of a Carbon data source configuration file can be found at
In the "init" methods of all custom data sources, user-supplied properties will be parsed to initialize the data source accordingly. Also, a property named "__DATASOURCE_ID__", which contains a UUID to uniquely identify the current data source, will be passed. This can be used by custom data source authors to identify the data sources accordingly. For example, scenarios like data source instances communicating within a server cluster for data synchronization.
Shown below is an example configuration of a custom data source of type 'DS_CUSTOM_TABULAR'.