Setting up VARS on PostgreSQL

VARS can run on most database servers. Below is the documentation to setup VARS to run on PostgreSQL

Installing PostgreSQL

To install PostgreSQL please refer to the documentation at

Configuring PostgreSQL

Once the PostgreSQL database server is installed you can create and configure a VARS database as follows:
  1. Initialize a database: [ Note /var/local/pgsql/data is just an example path. You may change that to suit your needs.]
    initdb -D /var/local/pgsql/data
  2. Modify /var/local/pgsql/data/postgresql.conf to allow TCP/IP connections from anyhost. Add the following line:
  3. Modify /var/local/pgsql/data/pg_hba.conf to allow connections from anyhost. Add the following line:
    host  VARS  varsuser password
  4. Start PostgreSQL:
    postgres -D /var/local/pgsql/data
  5. Create the vars database with the following command:
    createdb VARS
  6. Create a varsuser account. The user account needs to have aleast read/write/modify privelages. [Remember the password you use!! You'll need that later]
    createuser varsuser --password

Set up the VARS database on PostgreSQL

Once you've initialize a database, you will need to create the database tables that VARS needs. You can use your favorite database utility or you can use PostgreSQL's command line utility psql to run the table definitions below.

Configuring VARS

VARS will need to be modified to recognize your database.
  1. Find and download the JDBC driver for your version of postgreSQL from (JDBC type 4 driver is best). Just download the driver and drop it into VARS_HOME/lib.
  2. Note the following information. The default port for PostgreSQL is 5432 unless you changed it in postgresql.conf. The host is the either the fully qualified name or the IP address of the computer running PostgreSQL. Either the name or the IP address wil work.
    JDBC URL: jdbc:postgresql://HOST:PORT/DATABASE [varies with your computer]
    USERNAME: ??? [probably will be 'varsuser' if you followed the directions above]
    PASSWORD: ??? [From above]
    DRIVER NAME: org.postgresql.Driver
  3. Make a temp directory somewhere to work in:
    mkdir tempdir;cd tempdir
  4. Copy the vars-jpa-XXX.jar from VARS_HOME/lib into the tempdir.
    cp $VARS_HOME/lib/vars-jpa-6.0.2.jar tempdir
  5. Unzip the vars-jpa jar. [JAR files are just zip files with a different extension].
    cd tempdir; mkdir trashme; unzip vars-jpa-6.0.2.jar -d trashme
  6. Edit the following files:
    • trashme/
    • trashme/
    • trashme/
    • trashme/META-INF/persistence.xml
    Inside each of these files are lines that specify the jdbc-url, username, password, and driver name of the databases. Edit them as appropriate. If you've munged the VARS and VARS_KB tables into a single database [which is what these directions assume] then you'll only have one url to use everywhere, otherwise be mindful of which database you point at. For example, and should point at the VARS database. The file should point at the VARS_KB database.
    persistence.xml has several XML blocks named 'persistence-unit' in it. The ones named 'vars-jpa-knowledgebase', and 'vars-jpa-misc' should point at VARS_KB. 'vars-jpa-annotation' should point at the VARS database. You don't care about the 'vars-jpa-test' persistence unit.
  7. Once you've made edits you need to jar everything back up.
      # Assuming you're still in tempdir
      jar -cvf vars-jpa-6.0.2-postgresql.jar -C trashme *
    This will create a new jar named vars-jpa-6.0.2-postgresql.jar. Delete VARS_HOME/lib/vars-jpa-6.0.2.jar and replace it with your new jar (VARS will automatically pick up the changes when you start it