Skip to content

Getting Started With VoltDB, JDBC and Railo

wijjo edited this page Apr 19, 2012 · 3 revisions

Getting Started with VoltDB, JDBC and Railo

These instructions should get you up and running with VoltDB and Railo on Linux or Macintosh. It was tested on Ubuntu 11.10 and OS X Lion (10.7), but can be easily adjusted for other Linux distributions. Some of the paths may vary between distributions, e.g. for Apache, and may require additional installed software. Other recent OS X versions should also work fine.

Install Railo on Linux

Prerequisites

Apache is a prerequisite. Use the package manager, e.g. Synaptic, to install Apache as needed.

Download and Run the Installer

  • Get the appropriate Railo binary installer from http://getrailo.org, e.g. railo-_version_-linux-x64-installer.run".

  • Make the downloaded Railo bin file executable.

chmod +x railo-_version_-linux-x64-installer.run
  • Run the installer as root.
sudo ./railo-_version_-linux-x64-installer.run

Installer Option Choices

  • Accept or change the installation directory.
  • Accept or change users and passwords.
  • Accept or change the server port (default is 8888).
  • Do not install the Apache Connector if you want to avoid configuring it for Apache.

Install Railo on Macintosh

Download and Run the Installer

  • Get the appropriate Railo Macintosh binary installer from http://getrailo.org.

  • railo-_version_-osx-installer.run.

  • Unpack the archive to extract the installer application.

  • Run the installer application.

Installer Option Choices

  • Accept or change the installation directory.
  • Accept or change users and passwords.
  • Allow it to start at boot time.

Install VoltDB

  • Download the appropriate deployment kit from http://voltdb.com/products-services/downloads. For example:
  • For 64 bit Ubuntu you can choose the 64 bit Linux deployment kit.
  • For Macintosh you can choose the 64 bit Mac deployment kit
  • Unpack the files into chosen directory, e.g. ~/voltdb. Note that you will need write permission in order to run the voter demo.
  • If necessary install Java.
  • On Ubuntu you can select "default-jre" or "default-jdk" in the Synaptic Package Manager.
  • Macintosh computers should already have working Java environments.

Start the VoltDB Voter Server

If you pre-start the voter example server then Railo verification of the JDBC datasource will pass.

  • Run the voter example server from the examples/voter directory.
cd examples/voter
./run.sh server

Install the VoltDB Client Jar File

On Linux, assuming you installed railo to /opt and your working directory is the root of the unpacked distribution archive, you can run the following command.

sudo cp voltdb/voltdbclient-2.5.jar /opt/railo/lib

On Macintosh, assuming you installed railo to /Library and your working directory is the root of the unpacked distribution archive, you can run the following command.

sudo cp voltdb/voltdbclient-2.5.jar //Library/Railo/lib

Restart Railo

Restarting Railo allows the Tomcat server to recognize the newly-installed VoltDB jar.

On Linux you might run the following command.

sudo service railo_ctl restart

or

sudo /etc/init.d/railo_ctl restart

On Macintosh this is how you restart the Railo tomcat server.

sudo launchctl stop org.railo.tomcat
sudo launchctl start org.railo.tomcat

Add the Datasource to Railo

org.voltdb.jdbc.Driver
  • Specify the DSN (datasource connection string). Assuming the default port, 21212, it would be the following.
jdbc:voltdb://localhost:21212
  • Save and note that the new datasource appears in the list.

Create the Test Application

Place the following example code in a .cfm file (e.g. voter.cfm) in the Tomcat web applications root directory.

On Linux the default path would be /opt/railo/tomcat/webapps/ROOT/voter.cfm.

On Macintosh the default path would be /Library/Railo/tomcat/webapps/ROOT/voter.cfm.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>VoltDB Railo Voter Test</title>
    </head>
    <body>
        <h3>VoltDB Railo Voter Test</h3>
        <cftimer type="outline">
            <div class="header">Initializing</div>
            <cfstoredproc procedure="Initialize" datasource="voltdb" >
                <cfprocparam type="IN" cfsqltype="cf_sql_integer" value="2">
                <cfprocparam type="IN" cfsqltype="cf_sql_string" value="Wanda,Arnold">
                <CFPROCRESULT NAME = RS1>
            </cfstoredproc>
            <div class="header">Generating votes</div>
            <cfflush interval="1000">
            <cfloop from="1" to="50000" step="1" index="counter">
                <cfstoredproc procedure="Vote" datasource="voltdb" >
                    <cfprocparam type="IN" cfsqltype="cf_sql_integer" value="8005551212">
                    <cfprocparam type="IN" cfsqltype="cf_sql_integer" value="1">
                    <cfprocparam type="IN" cfsqltype="cf_sql_integer" value="100000">
                    <CFPROCRESULT NAME = RS1>
                </cfstoredproc>
            </cfloop>
        </cftimer>
        <br />
        <cfquery name="getCount" datasource="voltdb">
        select count(*) as total from votes;
        </cfquery>
        <div class="header">Total inserts:  <cfoutput>#getCount.total#</cfoutput></div>
    </body>
</html>

Run the Test Application

  • Go to the application home page.

  • On Linux with the default port it would be http://localhost:8888/voter.cfm.

  • On Macintosh it would default to http://localhost/voter.cfm.

  • It should display the following and pause for a while as it generates 50000 identical votes.

    VoltDB Railo Voter Test

    Initializing

    Generating votes

  • Eventually you should see an elapsed time and an insert count. The page should look something like this.

    VoltDB Railo Voter Test

    Initializing

    Generating votes

    : 14392ms

    Total inserts: 50000