Server Configuration
Prev | Chapter 81. MySQL Database Use | Next

## Server Configuration

Now you have to change configuration to load jdbc module instead of XML based repository. Using configuration management script, first change class name handling repository.

To see current settings run command:

    $ ./scripts/config.sh -c tigase-config.xml -print -key session_1/user-repo-class

As a result you should see something like:

    session_1/user-repo-class = tigase.db.xml.XMLRepository

You can see that current setting points to XML repository implementation. To use jdbc module for connection to MySQL database you have to set tigase.db.jdbc.JDBCRepository class (enter text below in one line):

    $ ./scripts/config.sh -c tigase-config.xml -print
          -key session_1/user-repo-class -value tigase.db.jdbc.JDBCRepository -set

As a result you will see new value set for the parameter:

    session_1/user-repo-class = tigase.db.jdbc.JDBCRepository

You have also to set the same value as authorization repository unless you want to use different authorization data source:

     $ ./scripts/config.sh -c tigase-config.xml -print
          -key session_1/auth-repo-class -value tigase.db.jdbc.JDBCRepository -set

And again as a result we can see:

    session_1/auth-repo-class = tigase.db.jdbc.JDBCRepository

Next step is to set database connection string. Assuming you have database: tigase on localhost with database user: dbuser and password dbpass your connection string will look like this:

    jdbc:mysql://localhost/tigase?user=dbuser&password=dbpass

To set this in your configuration file you have to call again configuration management script 2 times. First for user data repository and second for authorization data repository:

    $ ./scripts/config.sh -c tigase-config.xml -print -key session_1/user-repo-url
           -value "jdbc:mysql://localhost/tigase?user=dbuser&password=dbpass" -set
    $ ./scripts/config.sh -c tigase-config.xml -print -key session_1/auth-repo-url
           -value "jdbc:mysql://localhost/tigase?user=dbuser&password=dbpass" -set

Note quotes around connection string. They are needed to make sure shell won’t interpret special characters.

Now your configuration is ready to load jdbc module and connect to your database.

One more thing you need to do is to tell JVM which jdbc driver to use to connect to database. Depending on your MySQL and jdbc installation it might be: com.mysql.jdbc.Driver. To set is as database driver you have to set is a jdbc.drivers property value. Usually you do this by adding -D parameter to Java call:

     $ java -Djdbc.drivers=com.mysql.jdbc.Driver tigase.server.XMPPServer

If you use tigase.sh script to run server you have to add -Djdbc.drivers=com.mysql.jdbc.Driver to startup script <initProperties,property file>> to JAVA_OPTIONS values.

Prev | Up | Next
Chapter 81. MySQL Database Use | Home | User Data Import