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/.

Configuring master-datasources.xml

Users can change the default configurations by editing the <PRODUCT_HOME>/repository/conf/datasources/master-datasources.xml file using the information in the following table.

XML Elements 

Click on the table and use the left and right arrow keys to scroll horizontally. For sample values, see the Example below the table.

XML elementAttributeDescriptionData typeDefault valueMandatory/Optional
<datasources-configuration>xmlnsThe root element. The namespace is specified as: xmlns:svns="http://org.wso2.securevault/configuration"  Mandatory
<providers> The container element for the datasource providers.  Mandatory

<provider>

 The datasource provider, which should implement org.wso2.carbon.ndatasource.common
.spi.DataSourceReader
. The datasources follow a pluggable model in providing datasource type implementations using this approach.
Fully qualified Java class Optional
<datasources> The container element for the datasources.  Mandatory
<datasource> The root element of a datasource.  Mandatory
<name> Name of the datasource.String Mandatory
<description> Description of the datasource.String Optional
<jndiConfig> The container element that allows you to expose this datasource as a JNDI datasource.  Optional
<name> The JNDI resource name to which this datasource will be bound.String Mandatory if specifying JNDI configuration
<environment> 

The container element in which you specify the following JNDI 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.
Fully qualified Java class Optional
<definition>typeThe container element for the data source definition. Set the type attribute to RDBMS, or to custom if you're creating a custom type. The "RDBMS" data source reader expects a "configuration" element with the sub-elements listed below.String Mandatory
<configuration> The container element for the RDBMS properties.  Mandatory if definition type is RDBMS
<url> The connection URL to pass to the JDBC driver to establish the connection.URL Mandatory
<username> The connection user name to pass to the JDBC driver to establish the connection.String Optional
<password> The connection password to pass to the JDBC driver to establish the connection.String Optional
<driverClassName> The class name of the JDBC driver to use.Fully qualified Java class Mandatory
<maxActive> The maximum number of active connections that can be allocated from this pool at the same time.Integer100Optional
<maxWait> Maximum number of milliseconds that the pool waits (when there are no available connections) for a connection to be returned before throwing an exception.Integer30000 (30 seconds)Optional
<testOnBorrow> Specifies whether objects will be validated before being borrowed from the pool. If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another.
When set to true, the validationQuery parameter must be set to a non-null string.
BooleanfalseOptional
<validationQuery> The SQL query used to validate connections from this pool before returning them to the caller. If specified, this query does not have to return any data, it just can't throw a SQLException. The default value is null. Example values are SELECT 1(mysql), select 1 from dual(oracle), SELECT 1(MS Sql Server).StringnullMandatory when testOnBorrow is set to true
<validationInterval> To avoid excess validation, only run validation at most at this frequency (interval time in milliseconds). If a connection is due for validation, but has been validated previously within this interval, it will not be validated again. The default value is 30000 (30 seconds).Long30000 (30 seconds)Optional

Example

<datasources-configuration xmlns:svns="http://org.wso2.securevault/configuration">
  <providers>
    <provider>
    org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader
    </provider>
  </providers>
  <datasources>
    <datasource>
      <name>WSO2_CARBON_DB</name>
      <description>The datasource used for registry and user manager</description>
      <jndiConfig>
        <name>jdbc/WSO2CarbonDB</name>
      </jndiConfig>
      <definition type="RDBMS">
        <configuration>
          <url>
jdbc:h2:repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000
          </url>
          <username>wso2carbon</username>
          <password>wso2carbon</password>
          <driverClassName>org.h2.Driver</driverClassName>
          <maxActive>50</maxActive>
          <maxWait>60000</maxWait>
          <testOnBorrow>true</testOnBorrow>
          <validationQuery>SELECT 1</validationQuery>
          <validationInterval>30000</validationInterval>
        </configuration>
      </definition>
    </datasource>
  </datasources>
</datasources-configuration>