WSO2 Registry - Setting up Database - Derby

WSO2 Registry - Setting up Database - Derby (Embedded And Remote)

Table of Contents

Setting up Database - Derby Remote

Preparing the Derby Database

  1. Download and install Apache Derby in you computer, if it is not already done.
  2. Goto the <derby-installation directory>/bin directory and run the derby network server starting script. Usually this is named as "startNetworkServer".

Setup Configuration Files

  1. Edit the registry.xml file (inside the $CARBON_HOME/conf directory) of the deployed registry instance as below (note the highlighted configurations, You may use your own database name, username and password).
        <currentConfig>derby-db</currentConfig>
            <dbconfig name="derby-db">
                <url>jdbc:derby://localhost:1527/db;create=true</url>
                <userName>regadmin</userName>
                <password>regadmin</password>
                <driverName>org.apache.derby.jdbc.ClientDriver</driverName>
                <maxActive>80</maxActive>
                <maxWait>6000</maxWait>
                <minIdle>5</minIdle>
           </dbconfig>
    

    Explanation of the database configuraiton options.

    • url: The URL of the database
    • userName: The name of the database user
    • password: The password of the database user
    • maxActive: The maximum number of active connections that can be allocated from this pool at the same time, or negative for no limit.
    • maxWait: The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception, or <= 0 to wait indefinitely.
    • minIdle: The minimum number of active connections that can remain idle in the pool, without extra ones being created, or 0 to create none.

    NOTE: In contrast to the embedded registry, in remote registry you will set the database driver name ("driverName" element) to the value "org.apache.derby.jdbc.ClientDriver" and the database url ("url" element) to the database remote location.

  2. Edit the user-mgt.xml file (inside the $CARBON_HOME/conf directory) of the deployed instance as below (Note that you have to replace these settings with your custom values).
        <Database>
             <URL>jdbc:derby://localhost:1527/db;create=true</URL>
             <UserName>regadmin</UserName>
             <Password>regadmin</Password>
             <Dialect>derby</Dialect>
             <Driver>org.apache.derby.jdbc.ClientDriver</Driver>
         </Database>
    

Setup Drivers

  1. Place derby.jar, derbyclient.jar and derbynet.jar in the $CARBON_HOME/lib/extensions directory (to the class path of the WSO2 Registry web application)

Create Database

Automatic Database Creation

  1. Next at the first time you start the regisry, run with the -Dsetup option, so it will create the Derby database.

    wso2server.sh -Dsetup (in linux)

    wso2server.bat -Dsetup (in windows)

  2. You just configured WSO2 Registry to run using a remote Apache Derby database.

Manual Database Creation

  1. Run the ij tool located in the <derby-installation directory>/bin directory.
  2. Create the registry database and connect to it using the following command inside the ij prompt (replace the database file path, user name and password in below command to suite your requirements).

    connect 'jdbc:derby://localhost:1527/db;user=regadmin;password=regadmin;create=true';

  3. Now Exit from the the ij tool by typing the exit command.

    exit;

  4. Now login to the 'ij' tool with the username and password you just used to create the database.

    connect 'jdbc:Derby:db' user 'regadmin' password 'regadmin';

  5. Run the derby scripts for both registry and user manager (embedded inside the Registry) databases, provided with the WSO2 Registry using the below commands.

    run 'CARBON_HOME/dbscripts/common/derby-registry.sql';

    run 'CARBON_HOME/wso2registry/dbscripts/usermanager/um-derby.sql';

  6. Restart the wso2 registry instance. Now WSO2 Registry is running using a remote Apache Derby database!

Setting up Database - Derby - Embedded

Preparing the Derby Database

  1. Download and install Apache Derby in you computer, if it is not already done.

Setup Configuration Files

  1. Edit the registry.xml file (inside the $CARBON_HOME/conf directory) of the deployed registry instance as below (note the highlighted configurations, You may use your own database name, username and password).
        <currentConfig>derby-db</currentConfig>
            <dbconfig name="derby-db">
                <url>jdbc:derby:database/WSO2CARBON_DB;create=true</url>
                <userName>regadmin</userName>
                <password>regadmin</password>
                <driverName>org.apache.derby.jdbc.EmbeddedDriver</driverName>
                <maxActive>80</maxActive>
                <maxWait>6000</maxWait>
                <minIdle>5</minIdle>
           </dbconfig>
    

    Explanation of the database configuraiton options.

    • url: The URL of the database
    • userName: The name of the database user
    • password: The password of the database user
    • maxActive: The maximum number of active connections that can be allocated from this pool at the same time, or negative for no limit.
    • maxWait: The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception, or <= 0 to wait indefinitely.
    • minIdle: The minimum number of active connections that can remain idle in the pool, without extra ones being created, or 0 to create none.

    NOTE: In contrast to the remote registry, in embedded registry you will set the database driver name ("driverName" element) to the value "org.apache.derby.jdbc.EmbeddedDriver" and the database url ("url" element) to the database directory location relative to the registry installation. (In the above sample configuration it is inside the "database/WSO2CARBON_DB" directory)

  2. Edit the user-mgt.xml file (inside the $CARBON_HOME/conf directory) of the deployed instance as below (Note that you have to replace these settings with your custom values).
        <Database>
             <URL>jdbc:derby:database/WSO2CARBON_DB;create=true</URL>
             <UserName>regadmin</UserName>
             <Password>regadmin</Password>
             <Dialect>derby</Dialect>
             <Driver>org.apache.derby.jdbc.EmbeddedDriver</Driver>
         </Database>
    

Setup Drivers

  1. Place derby.jar, derbyclient.jar and derbynet.jar in the $CARBON_HOME/lib/extensions directory (to the class path of the WSO2 Registry web application)

Create Database

Automatic Database Creation

  1. Next at the first time you start the regisry, run with the -Dsetup option, so it will create the Derby database.

    wso2server.sh -Dsetup

    wso2server.bat -Dsetup

  2. You just configured WSO2 Registry to run using the embedded Apache Derby.

Manual Database Creation

  1. Run the ij tool located in the <derby-installation-directory>/bin directory.n directory>/bin directory.
  2. Create the registry database and connect to it using the following command inside the ij prompt (replace the database file path, user name and password in below command to suite your requirements).

    connect 'jdbc:derby:database/WSO2CARBON_DB;create=true';

    NOTE: Here you need to give the full path to your registry database in place of "/WSO2CARBON_DB"

  3. Now Exit from the the ij tool by typing the exit command.

    exit;

  4. Now login to the 'ij' tool with the username and password you just used to create the database.

    connect 'jdbc:Derby:db' user 'regadmin' password 'regadmin';

  5. Run the derby scripts for both registry and user manager (embedded inside the Registry) databases, provided with the WSO2 Registry using the below commands.

    run 'CARBON_HOME/dbscripts/common/derby-registry.sql';

    run 'CARBON_HOME/dbscripts/usermanager/um-derby.sql';

  6. start the wso2 registry instance.

    wso2server.sh (in linux)

    wso2server.bat (in windows)

    Now WSO2 Registry is running using the embedded Apache Derby database!