Updating the Existing Datasources
A datasource is a connection set up to a storage of data, i.e., a database or a data file, from a server. A datasource provides information that a server can use to connect to a storage of data. ES only uses the following two datasources:
Datasource | Description | Definition File Path |
---|---|---|
WSO2_CARBON_DB | This is used to store data of on the ES registry and user manager to a RDBMS. | <ES_HOME>/repository/conf/datasources/master-datasources.xml |
WSO2_SOCIAL_DB | This is used to persist Store-side social activities (e.g., comments, rating, likes etc.). | <ES_HOME>/repository/conf/datasources/social-datasources.xml |
Updating the existing datasources is the main use case that is applicable when working with ES. However, if you wish to learn more on working with datasources, see Managing Datasources.
Follow the steps below to update the existing datasources:
By default, ES uses the H2 DB. You need to update the existing datasources in ES when you use a DB that differs from the default DB.
Create a database driver.
- Download the driver JAR file of the respective RDBMS type.
- Copy the driver JAR file to the
<ES_HOME>/repository/components/lib
directory.
Update the
WSO2_CARBON_DB
datasource, which is defined in the<ES_HOME>/repository/conf/datasources/
master-datasources.xml
file, based on your requirements. For more information, see Datasource Configuration Definition.Update the
WSO2_SOCIAL_DB
datasource, which is defined in the<ES_HOME>/repository/conf/datasources/social-datasources.xml
file, based on your requirements. For more information, see Datasource Configuration Definition.Optionally, create a query adapter n ES.
ES is shipped with query adapters for H2, MySQL, MSSQL and Oracle11g. If you are using a different DB, than the DBs specified above, create a query adapter as follows:Create a custom query adapter by extending the
GenericQueryAdapter
and implementing the AdapterInterface.Create a JAR file for the custom query adapter.
Add the query adapter into the
<ES_HOME>/repository/components/lib
directory.
Optionally, update the query adapter in the
<ES_HOME>/repository/conf/social.xml
file. If you are using a DB other than H2 or MySQL, this step is mandatory.
By default, ES uses theorg.wso2.carbon.social.db.adapter.GenericQueryAdapter
query adapter, which is used for H2 and MYSQL. If you are using another DB type, replace the default query adapter with the query adapter that corresponds to your DB. For more information on the available query adapters, see Query adapters shipped with ES.<SocialConfig> <QueryAdapterClass>org.wso2.carbon.social.db.adapter.GenericQueryAdapter</QueryAdapterClass> </SocialConfig>
- Restart the ES server.
Query adapters shipped with ES
ES is shipped with the following query adapters, where org.wso2.carbon.social.db.adapter.GenericQueryAdapter
is the default query adapter.
DB Type | Query Adapter |
---|---|
H2 | org.wso2.carbon.social.db.adapter.GenericQueryAdapter |
MySQL | org.wso2.carbon.social.db.adapter.GenericQueryAdapter |
MSSQL | org.wso2.carbon.social.db.adapter.MSSQLQueryAdapter |
Oracle11g | org.wso2.carbon.social.db.adapter.Oracle11gQueryAdapter |
PostgreSQL | org.wso2.carbon.social.db. adapter.GenericQueryAdapter |