Using the JDBC Driver

The Mimer SQL distribution includes a JDBC driver. This driver enables Java programs running on OpenVMS to access a Mimer SQL database server.

The JDBC driver is a ‘type 4’ driver which means that it is written entirely in Java, and can be moved to any platform supporting Java.

The driver, MIMJDBC3.JAR, supports the JDBC 3 standard, and is for Java 1.4 or later.

 

For more information about Java and JDBC, please see:

SYS$COMMON:[JAVA*.DOCS]INDEX.HTML – Java information for more recent versions

MIMER$DOC:MIMJDBEN.PDF – Information on the Mimer JDBC driver.

https://www.oracle.com/technetwork/java/javase/jdbc/index.html – JDBC technology information.

Using the JDBC Driver

To use the JDBC driver, you must first set up the OpenVMS Java environment.

Defining Java Commands

Use the following command to define the Java commands (Java version 1.4.2 is used in the example):

$ @SYS$MANAGER:JAVA$142_SETUP

Setting CLASSPATH

To use a Mimer JDBC driver, the Java environment must be able to find it.

The logical name CLASSPATH is used for this purpose. This logical name contains a list of directories and Java archives (.ZIP and .JAR files).

On OpenVMS you can use either the JAVA$CLASSPATH or CLASSPATH logical name to specify a Java classpath. The JAVA$CLASSPATH logical name is easier to use since it uses standard OpenVMS file specifications.

Example

$ DEFINE JAVA$CLASSPATH MIMER$LIB:MIMJDBC3.JAR, SYS$DISK:[]

 

It is also possible to use the CLASSPATH logical name. This logical name uses a Unix syntax to specify a search path. Please read the OpenVMS Java documentation for details.

The following example sets the CLASSPATH logical name to include the Mimer JDBC 1 driver.

Since the equivalence string becomes rather long, and must be enclosed in quotes, a DCL string is constructed.

Example

$ SHOW LOG CLASSPATH

"CLASSPATH" = "/sys$common/java/lib/JDK118_CLASSES.ZIP:." (LNM$PROCESS_TABLE)

$ CLASSPATH=F$TRNLNM("CLASSPATH")+":/MIMER$LIB/MIMJDBC3.JAR"

$ DEFINE CLASSPATH "''CLASSPATH'"

 

The Mimer JDBC driver should now be accessible.

Note:Using logical names that enclose directory specifications with < and > is problematic in Java. Please make sure you use [ and ] instead.

Verifying the Environment

Since the driver contains a main() function, it is possible to execute it as a program for testing purposes.

Use the -version switch to verify that the Java environment can locate and use the Mimer JDBC driver. Note that quotes must be used since Java package names are case sensitive.

$ JAVA "com.mimer.jdbc.Driver" -version

Mimer JDBC driver version 3.31 (12385)

Testing the Connection

Use the -ping switch to test that the driver can make a connection with a Mimer SQL v10.1 database server.

Please read the JDBC driver guide for an explanation of the syntax of the connection URL.

$ java "com.mimer.jdbc.Driver" -ping "jdbc:mimer:local://SYSADM:SYSADM@/targetdb

Database connection established.

getDatabaseProductName():    Mimer SQL Experience

getDatabaseProductVersion(): 11.00.0000 Mimer SQL Experience 11.0.0a

 

Ping tests:

 0     0 ms

 1     0 ms

 2     1 ms

 3     0 ms

 4     0 ms

 5     1 ms

 6     0 ms

 7     0 ms

 8     0 ms

 9     0 ms

avg     0 ms      min     0 ms      max     1 ms

 

Finally, compile and execute the JDBC example program. You should copy the example program to a private directory and edit it in order to set the connection URL string, database user name and passwords.

$ SET DEF [SOMEWHERE.PRIVATE]

$ COPY MIMER$EXAMPLES:EXAMPLE.JAVA []

$ ! Edit the example. Alter the URL and username/password

$ EDIT EXAMPLE.JAVA

$ JAVAC EXAMPLE.JAVA

$ JAVA "Example"