Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Datasource management capability is provided by the following feature in the WSO2 feature repository:

Name : WSO2 Carbon - Datasource Management Feature
Identifier : org.wso2.carbon.datasource.feature.group

...

 

When the datasource management feature is installed in your instance, you can add datasources that allow the server to connect to databases and other external data stores.
To add a datasource:
  1. In the management console, click the Configure tab, and then click Data Sources.
  1. Image Modified  
2.
  1. Click Add Data Source.
  1. Image Modified  
3.
  1. Specify the required options
in the "New Data Source" page. Depending
  1. for connecting to the database. The required fields vary depending on the datasource type
, the required fields may vary. Discussed below are the two types available.
  1. you select:

RDBMS
Anchor
rdbms
rdbms

If When you select the "Data Source Type" as RDBMSRDBMS as the datasource type, the following screen will appear.appears:

Image Modified

This is the default RDBMS datasource configuration provided by WSO2. Users You can also write your own RDBMS configuration by selecting the Custom Data Source custom datasource option. The Enter values for the following fields should be provided when defining using the default RDBMS datasource .configuration:

  • Data Source Type: RDBMS
  • Name: Name of the datasource (This value should must be a unique .value)
  • Data Source Provider: Discussed below. Specify the datasource provider as described below
  • Driver: The JDBC driver to be used.use
  • URL: The connection URL to be passed pass to the JDBC driver to establish a the connection.
  • User Name: The connection user name to be passed pass to the JDBC driver to establish a the connection.
  • Password: The connection password to be passed pass to the JDBC driver to establish a the connection.
  • Expose as a JNDI Data Source : Discussed below. Souce: Allows you to specify the JNDI data source as described below
  • Data Source Configuration Parameters: Additional properties can be defined Allows you to specify advanced configuration properties when creating an RDBMS datasource. For more information on these properties, see Datasource Parameters.
The meaning of many fields is similar to the DBCPconfiguration guide, to which you can refer to for more information

Many of these fields are similar to those in DBCP. For more information, see: http://commons.apache.org/dbcp/configuration.html

4. After entering the values, click Save.

You can nowAfter creating datasources, you can edit and delete datasourcesthem as needed.

Datasource

...

provider
Anchor
pro
pro

...

When creating an RDBMS datasource, can use the default provider or link to an external provider.

...

To use the

...

default

...

datasource provider, select default, and then enter the connection properties Driver, URL, User Name, and Password as follows:

Image Modified

If you need to add a datasource supported by an external provider class such as

...

com.mysql.jdbc.jdbc2.optional.MysqlXADataSource

...

, select

...

External Data Source, click Add Property, and then enter the name and value of

...

each connection property you need to configure. Following is an example datasource for an external datasource provider.

Image Modified

JNDI Datasource
Anchor
jndi
jndi

Java Naming and Directory Interface (JNDI) is a Java application programming interface (API) that provides 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 datasource with JNDI, others can discover it through a JNDI look-up and use it.

To expose a datasource as a JNDI datasource,

...

click Expose as a JNDI Data Source

...

to display the JNDI fields:

Image Modified

Following is a description of the JNDI fields:

  • Name: Name of the JNDI datasource that will be visible to others in object look-up

...

  • Use Data Source Factory:

...

  • To make the datasource

...

  • accessible from an external environment,

...

  • you must use a data source factory. When this option is selected, a

...

  • reference object will be created with the defined datasource properties.

...

  • The data source factory will create the datasource instance based on the values of the

...

  • reference object when accessing the datasource from an external environment. In the datasource configuration, this is set as follows:
    <jndiConfig useDataSourceFactory="true"

...

  • >
  • JNDI Properties: Properties related to the JNDI datasource (such as password).

...

  • When you select this option, set the following properties

...

  • :

...

    • java.naming.factory.initial -

...

    • Selects the registry service provider as the initial context

...

...

    • java.naming.provider.url -

...

    • Specifies the location of the registry when the registry is being used as the initial context

...

Custom

...

datasource 
Anchor
custom
custom

If you select the

...

Custom datasource type, the following screen will appear

...

:

Image Modified

Specify the following fields:

  • Data Source Type: Custom

...

  • Custom Data Source Type:

...

  • Specify whether the data is in a table or accessed through a query as described below
  • Name: Enter a unique name for this datasource
  • Description: Description of the datasource
  • Configuration: XML configuration of the datasource

Custom

...

datasource type 
Anchor
CusDSType
CusDSType

...

When creating a custom datasource, specify whether the datasource type is DS_CUSTOM_TABULAR

...

(the data is stored in tables) or DS_CUSTOM_QUERY

...

(non-tabular data accessed through a query). Following is more information about each type.

Custom tabular datasources   

Tabular datasources are used

...

for accessing tabular data, that is, the data is stored in rows in named tables that can be queried later.

...

To implement tabular datasources, the interface

...

org.wso2.carbon.dataservices.core.custom.datasource.TabularDataBasedDS

...

is used.

...

You can see a sample implementation of a tabular custom datasource

...

at InMemoryDataSource.  

A tabular datasource is typically associated with a SQL data services query.

...

WSO2 products use an internal SQL parser to execute SQL against the custom datasource.

...

You can see a sample data service descriptor at InMemoryDSSample.

...

Carbon datasources

...

also support tabular data with the datasource reader implementation

...

org.wso2.carbon.dataservices.core.custom.datasource.CustomTabularDataSourceReader

...

. If you have Data Services Server installed, you can see a sample Carbon datasource configuration file

...

at

...

<DSS_HOME>\repository\conf\datasources\custom-datasources.xml.

Custom

...

query datasources

Custom query-based datasources are

...

used for accessing non-tabular data through a query expression

...

.

...

To implement query-based datasources, the interface

...

org.wso2.carbon.dataservices.core.custom.datasource.CustomQueryBasedDS

...

is used.

...

You can create any non-tabular datasource

...

using the query-based approach. Even if the target datasource does not have a query expression format,

...

you can create

...

and use your own. For example, you can support any NoSQL type datasource

...

using this type of a datasource.  

...

You can see a sample implementation of a custom query-based

...

datasource

...

at EchoDataSource.

...

You can see a sample data service descriptor with custom query datasources

...

in

...

InMemoryDSSample.

...

Carbon datasources

...

also support query-based data with the datasource reader implementation org.wso2.carbon.dataservices.core.custom.datasource.CustomQueryDataSourceReader.

...

If you have Data Services Server installed, you can see a sample Carbon datasource configuration file

...

at

...

<DSS_HOME>\repository\conf\datasources\custom-datasources.xml.

...

In the "init" methods of all custom datasources, user-supplied properties will be parsed to initialize the datasource accordingly. Also, a property named "__DATASOURCE_ID__", which contains a UUID to uniquely identify the current datasource, will be passed. This can be used by custom datasource authors to identify the datasources accordingly

...

, such as datasource instances communicating within a server cluster for data synchronization.

Shown below is an example configuration of a custom datasource of type 'DS_CUSTOM_TABULAR'.

Image Modified

...

4. After entering the values, click Save.

...