Programming with SQL Relay using JDBC

The SQL Relay distribution does not provide a native JBCD driver, but by using the ODBC-to-JDBC bridge provided by most Java distributions, applications which use JDBC on Unix or Linux may access databases through SQL Relay via the experimental ODBC driver.

See Programming with SQL Relay using ODBC for instructions detailing how to access SQL Relay through ODBC. Once that is working, you can access databases through SQL Relay via JDBC as well.

A good program to test this with is HenPlus, a JDBC command line client. After downloading and installing HenPlus, you can run it as follows:

> henplus jdbc:odbc:sqlrtest

Here is a sample session:

>     [mused@localhost bin]$ ./henplus jdbc:odbc:sqlrtest
>     no readline found (no JavaReadline in java.library.path). Using simple stdin.
>     using GNU readline (Brian Fox, Chet Ramey), Java wrapper by Bernhard Bablok
>     henplus config at /home/mused/.henplus
>     ---------------------------------------------------------------------------
>      HenPlus II 0.9.7 Copyright(C) 1997..2006 Henner Zeller <H.Zeller@acm.org>
>      HenPlus is provided AS IS and comes with ABSOLUTELY NO WARRANTY
>      This is free software, and you are welcome to redistribute it under the
>      conditions of the GNU Public License <http://www.gnu.org/licenses/gpl.txt>
>     ---------------------------------------------------------------------------
>     HenPlus II connecting
>      url 'jdbc:odbc:sqlrtest'
>      driver version 2.1
>      SQL Relay - 0.40
>      read committed
>     sqlrtest@odbc> create table test (col1 varchar(100));
>     affected 0 rows (43 msec)
>     sqlrtest@odbc> insert into test values ('hello');
>     affected 1 rows (14 msec)
>     sqlrtest@odbc> insert into test values ('bye');
>     affected 1 rows (5 msec)
>     sqlrtest@odbc> select * from test;
>     -------+
>      col1  |
>     -------+
>      hello |
>      bye   |
>     -------+
>     2 rows in result (first row: 91 msec; total: 160 msec)
>     sqlrtest@odbc> quit
>     storing settings..

Similarly, any program that uses JDBC can be configured to use SQL Relay via JDBC by setting its database url to jdbc:odbc:DSN where DSN is replaced with the ODBC DSN defined in /etc/odbc.ini.

Developing applications which use JDBC is beyond the scope if this document but many examples and tutorials may be found on the web.