A datasource provides information that a server can use to connect to a database or to an external data store. There are two ways of creating datasources for your server as explained below.
Datasources for Services and Resources
This section of the documentation explains how datasources are defined and used at the server level, i.e., how the product server connects to databases or external data stores using datasources. For information on how datasources can be defined inline for each data service, see the documentation on creating data service using various datasources.
Managing datasources using the management console
The following feature in the WSO2 Feature Repository allows you to manage datasources using the management console of your product:
Name: WSO2 Carbon - datasource management feature
Identifier: org.wso2.carbon.datasource.feature.group
If this feature is not included in your product by default, you can install it using the Feature Management section of this documentation. With this feature, you can add any RDBMS datasource or your own custom datasources using the management console, which can later be edited or deleted for your product instance if required. Note that all datasources created using the management console are saved to the registry of your product. The steps for creating datasources are discussed in the following topics:
Managing datasources using configuration files
In all WSO2 products, you also have the option of creating datasources be simply creating a configuration file with the datasource information and storing it in the <PRODUCT_HOME>/repository/conf/datasources/
directory. For example, all WSO2 products are shipped with the default WSO2_CARBON_DB database, and the datasource that is used to connect to this database is defined in the master-datasources.xml
file stored in the datasources
folder. You can also create your own custom datasources by creating configuration files and storing them in the same folder. For example, see the custom-datasources.xml
file. The datasources defined using configuration files can be viewed using the management console if the datasource management feature is installed.
When adding an RDBMS datasource, be sure to copy the JDBC driver JAR file for your database to <PRODUCT_HOME>/repository/components/lib
.