1.0

Table Of Contents
In a separate terminal prompt, start the mysql client and create a new database and table denition. Log on
using an account that has privileges to create a new database. For example:
mysql -u my_username -p
mysql> create database sqlfdb;
mysql> use sqlfdb;
mysql> create table sqlftest
-> (id int not null, name varchar(10));
You will create a table of the same name, "sqlftest," in SQLFire, and associate it with a DBSynchronizer.
2. Congure JDBC connectivity to the third-party database
DBSynchronizer requires a JDBC driver and connection URL to connect to the third-party database and
apply DML operations. Before you congure DBSynchronizer, use a Java client application such as SQuirreL
SQL to verify that you can connect to the database.
In the MySQL example shown in this procedure, the components necessary to establish a JDBC connection
are:
Driver JAR le: mysql-connector-java-5.1.18-bin.jar
Driver class: com.mysql.jdbc.Driver
Connection URL: jdbc:mysql://localhost:3306/sqlfdb?user=username&password=password
To ensure that SQLFire can access the JDBC driver class, add the JAR location to your CLASSPATH. For
example, open a new command prompt and enter:
export CLASSPATH=$CLASSPATH:/path/mysql-connector-java-5.1.18-bin.jar
3. Start a SQLFire data host in a custom server group
When you create a new AsyncEventListener such as DBSynchronizer, you must assign the listener to an
available server group. For example, to start a SQLFire data store and add it to a named server group:
mkdir sqlfdbsync
cd sqlfdbsync
export CLASSPATH=$CLASSPATH:/path/mysql-connector-java-5.1.18-bin.jar
sqlf server start -server-groups=dbsync &
This starts a new SQLFire data store server and assigns it to the "dbsync" server group.
4. Create the AsyncEventListener conguration
Connect to SQLFire and create a new AsyncEventListener using the DBSynchronizer. Ensure that you have
added the third-party JDBC driver JAR le to your classpath, then start sqlf and create the listener denition:
export CLASSPATH=$CLASSPATH:/path/mysql-connector-java-5.1.18-bin.jar
sqlf
sqlf> connect client 'localhost:1527';
sqlf> create asynceventlistener testlistener
> (
> listenerclass 'com.vmware.sqlfire.callbacks.DBSynchronizer'
> initparams
>
'com.mysql.jdbc.Driver,jdbc:mysql://localhost:3306/sqlfdb,username,password'
> )
> server groups (dbsync);
The INITPARAMS argument must specify the full JDBC driver class name to use and the JDBC connection
string, separated by a comma. Notice that the INITPARAMS also includes the username and password
separated by columns, and it does include those values as part of the connection URL (using
?user=username&password=password). Using the comma-separated arguments ensures that the password
value does not appear in external exception messages.
vFabric SQLFire User's Guide194
Caching Data with vFabric SQLFire