How To
Get Started with Mimer JDBC
Categories: JDBC, Programming Examples

The Mimer JDBC Driver provides access to Mimer databases from Java applications and applets. The driver is written entirely in Java, which makes it a type 4 JDBC-driver.


The latest driver requires JDK 1.2 and a Mimer SQL database server of version 8.2 or later.

Since JDK 1.2 is not available for all environments, you can use the JDBC 1 driver, which requires JDK 1.1 or later. See Downloads for instructions on how to download the JDBC 1 driver. The JDBC 1 driver also requires a Mimer SQL 8.2 database server or later.

Driver Characteristics
The Mimer JDBC driver is thread safe and uses one lock per connection. This means that the driver only allows one concurrent activity towards the server at one time. To achieve higher concurrency, an application should try to use several connections.

The driver is implemented to perform automatic prefetch, that is, whenever a result set is created, a buffer is filled with several successive rows. This is an optimization for throughput, allowing more data to be fetched to the client in the single communication made.

However, the response time, that is, the elapsed time before the first record will show up, is not optimized. You can customize the prefetch size using the Statement.setFetchSize() method. The default is to fetch about 60 KB; the exact number of rows depends on the size of the rows.

Both the JDBC specification and the Java language lack support for INTERVAL data types. The methods getString and setString can be applied for values accessed by the driver from database columns containing INTERVAL data.

By using the java com.mimer.jdbc.Driver command, you can view the characteristics of a specific driver and the current environment. Used without any arguments it will display its usage information:
java com.mimer.jdbc.Driver
Usage: com.mimer.jdbc.Driver options
where options include:
-version     Display driver version
-sysprop Display all system properties
-errors List all JDBC error codes
-ping url Test the database at the specified url
The following is an example that uses the -version option:
java com.mimer.jdbc.Driver -version
Mimer JDBC driver version 2.1

Logging and Trace Facilities
The Mimer JDBC Driver performs minimal logging activities to keep the driver size small and to optimize performance.

It is possible for an application to get statistical information from a database access. When a Connection object is closed, a statistics report is sent via the DriverManager log stream. From an application, you can choose to manage this information and, for example, display the report on screen or write it to a log file.

The report contains the following information:
  • Timestamp when the Statistics object was created
  • Number of server requests
  • Number of bytes sent/received
A separate trace driver is available for additional logging. The trace driver is a full JDBC Driver that covers all of JDBC by calling the matching routines of the traced JDBC Driver. The trace driver produces a log entry of every JDBC call the application makes, and also measures the elapsed time for each call. The trace log can be written to a file, or can be displayed directly in a window.

You invoke the trace driver using a special URL that contains the URL of the driver to be traced. See the Mimer JDBC Trace Driver Guide.

About Mimer JDBC Driver Version Numbering
The major version number is equal to the major version number of the JDBC specification that the driver supports. The minor version number is the release number of the driver.


You access a Mimer SQL database server from Java by specifying a URL.

URL syntax
Use the following URL syntax when connecting to Mimer SQL:
...where the URL-field-list syntax is as follows:
[//[user[:password]@]host[:port]] [/database]

Note: all items are optional, but to connect without specifying a database is rather unpredictable. A host specification, with or without a user specification, is introduced by '//' and a database specification is introduced by '/'

...and where the property-list syntax is as follows:

Note: you must use a leading question mark ('?') and if several properties are to be defined, separate them using ampersands ('&').

Recognized Properties
The driver recognizes the following properties:
  • databaseName -- Name of the database server to access
  • user – The user name used to log in to the database
  • password – The password used for the login
  • serverName – The computer on which the database server is running (the default is localhost)
  • portNumber – The port number to use on the server host (the default is 1360)

URL Examples
The following examples describe URL usage. Wherever suitable, field and property-based URL syntax, or a combination of both, is given.

Specifying a Database
The examples below connect to the customers database on the default host localhost using the default port 1360:

Specifying Node and Database
The examples below connect to the customers database on the host using the default port 1360:

Specifying Mimer-user, Node and Database
The examples below connect to the customers database on the host as user SYSADM using the default port 1360:

Specifying Mimer-user and Password, Node, Port Number and Database
The examples below connect to the customers database on the host using port 1366. Database login will be performed using the SYSADM user and the SYSPW password:


Loading the Driver
To be able to use the Mimer JDBC Driver, it must be loaded into the Java environment. To achieve this, a program loads a driver explicitly by calling the Class.forName method with the driver class as the parameter. The name of the Mimer driver class is: com.mimer.jdbc.Driver; see the JDBC application example below.
The driver is then located by the Java environment by searching along the class path, defined in the CLASSPATH environment variable.

The CLASSPATH environment variable informs the Java environment where to find Java class files, for example, those in, those delivered with the Mimer JDBC Driver and any other class files used by the applications.

Add the Mimer JDBC Driver jar file, including the directory specification, to the Java class path. For example:

Unix style:

Windows style:

Besides defining the CLASSPATH environment variable explicitly, you can also define it for a specific session when executing the application. For example:
java -classpath /usr/lib/mimjdbc-2_1.jar JdbcApplication

JDBC Application Example
The example Java program below creates a result set containing all rows of the data dictionary view INFORMATION_SCHEMA.TABLES. Each row is then read and displayed on the standard output.
In the example, the user name and password are given separately using the DriverManager.getConnection method, that is, they are not given in the URL specification:
import java.sql.*;

class Example
public static void main(String[] args)
try {
String url = "jdbc:mimer://";
Connection con =
DriverManager.getConnection(url, "SYSADM", "SYSPW");
Statement stmt = con.createStatement();
String sql = "select TABLE_SCHEMA,TABLE_NAME,TABLE_TYPE from
ResultSet rs = stmt.executeQuery(sql);
while ( {
String schema = rs.getString(1)
String name = rs.getString(2);
String type = rs.getString(3);
System.out.println(schema+" "+name+" "+type);
} catch (SQLException e) {
while (e != null) {
System.out.println("SQLState : "+e.getSQLState());
System.out.println("Message : "+e.getMessage());
System.out.println("ErrorCode : "+e.getErrorCode());
e = e.getNextException();
} catch (Exception e) {
System.out.println("Other Exception");
Another way to provide connection properties is to supply a java.util.Properties object to the DriverManager.getConnection method.

Note: the example program above is similar to the simple example program written in Embedded SQL that is included in the standard Mimer SQL database server distribution.

Using the Driver from Applets
If you want to use the example program above as an applet, you must modify it slightly, as can be seen in the following example:
import java.sql.*;
import java.applet.*;
import java.awt.*;

public class ExampleApplet extends java.applet.Applet {
public void init() {
resize(1200, 600);

public void paint(Graphics g) {
int row = 1;
g.drawString("Listing tables:", 20, 10 * row++);
try {
String url = "jdbc:mimer://";
Connection con =
DriverManager.getConnection(url, "SYSADM", "SYSPW");
Statement stmt = con.createStatement();
String sql = "select TABLE_SCHEMA,TABLE_NAME,TABLE_TYPE from
ResultSet rs = stmt.executeQuery(sql);
while ( {
String schema = rs.getString(1);
String name = rs.getString(2);
String type = rs.getString(3);
g.drawString(schema+" "+name+" "+type, 50, 10*row++);
} catch (SQLException e) {
g.drawString("SQLException!", 20, 10 * row++);
while (e != null) {
g.drawString("SQLState : "+e.getSQLState(), 20, 10*row++);
g.drawString("Message : "+e.getMessage(), 20, 10*row++);
g.drawString("ErrorCode : "+e.getErrorCode(), 20, 10*row++);
e = e.getNextException();
g.drawString("", 20, 10*row++);
} catch (Exception e) {
g.drawString("Other Exception!", 20, 10 * row++);
g.drawString(e.toString(), 20, 10 * row++);
To use the Mimer JDBC Driver in a Java applet, copy the driver jar file to the same location as that of the applet’s other Java classes. This directory must be accessible by the Web server. Specify the driver jar file name as the ARCHIVE parameter of the applet tag in the HTML file, as can be seen in the following example:
<title> The Example Applet
Example Applet:

<applet archive="mimjdbc-2_1.jar" code="ExampleApplet.class"
width=800 height=600>

Execute the applet by accessing the HTML file from a browser:

Note: a security restriction for Java applets states that a network connection can only be opened to the host from which the applet itself was downloaded. This means that the Web server distributing the applet code and the database server must reside on the same host computer.

Programming Considerations

Closing Objects
Although Java has automatic garbage collection, it is essential to close JDBC objects, such as ResultSets, Statements and Connections, when done with them. By performing correct close operations, the application gains better control over resources. Without proper close operations, resources are kept allocated in the database server until garbage collection is triggered. This can lead to exhaustion of server resources.
One of the main issues when trying to increase performance is to reduce the network traffic. For example, you can use the server to provide more accurate data instead of having a large, unqualified amount of data passed over to the client side where the application must sort out the specific data of interest.
You can achieve this by using more advanced SQL statements or by using stored procedures (PSMs). Note that in this respect, as said before, ResultSets are already optimized by the driver itself (using array fetch). If you know that only a small number of records are to be fetched, then use the setMaxRows method to optimize the response time and avoid an array fetch.
Another performance issue is to avoid "compilations" of SQL statements. Such compilations are done whenever Statement.executeXXX methods are invoked. Instead, use parameterized precompiled statements, that is, PreparedStatement, whenever possible.
The Mimer JDBC driver supports transactions. By default, autocommit is enabled, which means all transactions are ended as soon as possible. If you want to execute several inserts in one transaction, you must turn autocommit off using the Connection.setAutoCommit() method.

JDBC enables database connectivity from the Java programming language. This provides a modern solution that is open and portable.


You can find more information at:

Last updated: 2002-08-27


Powered by Mimer SQL

Powered by Mimer SQL