HowTo setup a C-JDBC Database

Note: For further informaton about Configuration of a clustered database in RAID1, refer to the ObjectWeb documentation. This configuration starts three HSQL instances that are formed by c-jdbc as raid 1. This means that the same data is stored in two different databases and one database is used as a recovery log.
  1. Download the c-jdbc binaries from the c-jdbc site.

  2. Extract the c-jdbc archive in a folder.
    tar xvfz c-jdbc-xx-bin.tar.gz

  3. Set the environment variables.
    export JAVA_HOME=<Path to JDK HOME>
    export CJDBC_HOME=<Path to the CJDBC HOME>

  4. Modify the $CJDBC_HOME/demo/demo-raidb1.sh file.
    The ports for the HSQLDB instances must be modified to match the sampleCluster2. Change the ports for the three databases to 11001, 11002, 11003.

  5. Configure the c-jdbc controller file:
    $CJDBC_HOME/config/virtualdatabase/hsqldb-raidb1.xml
    Change: modify the ports according to the values defined in the section above. To avoid problems in the Datasource configuration of JOnAS, you must also set a password for the users to log in.

    Backup original configuration:
    mv $CJDBC_HOME/config/controller/controller.xml $CJDBC_HOME/config/controller/controller.xml.original

    Create the link for the new configuration:
    ln -s $CJDBC_HOME/config/controller/controller-raidb1.xml $CJDBC_HOME/config/controller/controller.xml

    Modify the file:
    $CJDBC_HOME/config/controller/controller.xml

    Specify the configuration file of the virtual database in this file. The configuration file is:
    $CJDBC_HOME/config/virtualdatabase/hsqldb-raidb1.xml

  6. Start the HSQL instances.
    $CJDBC_HOME/demo/demo-raidb1.sh

  7. Start the cjdbc controller.
    $CJDBC_HOME/bin/controller.sh

  8. Connect to the cjdbc controller using the JDBC driver in $CJDBC_HOME/drivers and the url:
    jdbc:cjdbc://localhost:25322/myDB with username: <user> and password: <pass>
    Note: No password is specified by default. You should specify one in $CJDBC_HOME/config/virtualdatabase/hsqldb-raidb1.xml.


    Sample configuration of a c-jdbc database in JOnAS:

    ###################### C-JDBC DataSource configuration example
    #
    #####
    DataSource configuration
    #
    atasource.name jdbc_1
    datasource.url jdbc:cjdbc://localhost:25322/myDB
    datasource.classname org.objectweb.cjdbc.driver.Driver
    datasource.username user
    datasource.password pass
    datasource.mapper rdb.hsql
    # REMARK: You must specify the mapper of the databases used as backend by c-jdbc.
    # It is not possible to use a heterogenious c-jdbc configuration here.