Wednesday, September 25, 2013

How to set MySql data-source on WSO2 product

Today I'm going to explain how to set your MySql datasource to WSO2 product. You can simply do this by few number of steps.


  1. Create new data in your MySql database say 'userstore'
      • CREATE DATABASE userstore;
  2. Copy  your mysql connector jar (ex: mysql-connector-java-5.1.12-bin.jar) to PRODUCT_HOME/repository/components/lib directory.
  3. Now go to master-datasource.xml file at PRODUCT_HOME/repository/conf/datasources
  4. Replace the datasource tag with the following,
 <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:mysql://localhost:3306/userstore?autoReconnect=true</url>
           <username>root</username>
           <password>123</password>
           <driverClassName>com.mysql.jdbc.Driver</driverClassName>
           <maxActive>50</maxActive>
           <maxWait>60000</maxWait>
           <testOnBorrow>true</testOnBorrow>
           <validationQuery>SELECT 1</validationQuery>
           <validationInterval>30000</validationInterval>
      </configuration>
      </definition>
 </datasource>

Set your MySql url, username and password accordingly.

Once you start your server with sh ./wso2server.sh -Dsetup all the required scripts will be run and your database base will be updated.

Now you are ready to go :)


No comments:

Post a Comment