INFORMIX
Informix JDBC Driver Programmer's Guide
Chapter 2: Programming with Informix JDBC Driver
Contents Index

Other Informix Extensions to the JDBC API

This section describes the Informix-specific extensions to the JDBC API not already covered in this guide. These extensions handle information that is specific to Informix databases.

Another Informix extension, the com.informix.jdbc.Message class, is fully described in "Handling Errors".

Using the Informix SERIAL and SERIAL8 Data Types

Informix JDBC Driver provides support for the Informix SERIAL and SERIAL8 data types via the methods getSerial() and getSerial8(), which are part of the implementation of the java.sql.Statement interface.

Since the SERIAL and SERIAL8 data types do not have an obvious mapping to any JDBC API data types from the java.sql.Types class, you must import Informix-specific classes into your Java program to be able to handle SERIAL and SERIAL8 table columns. To do this, add the following import line to your Java program:

Use the getSerial() and getSerial8() methods after an INSERT statement to return the serial value that was automatically inserted into the SERIAL or SERIAL8 column of a table, respectively. The methods return 0 if any of the following conditions are true:

If you execute the getSerial() or getSerial8() method after a CREATE TABLE statement, the methods return 1 by default (assuming the new table includes a SERIAL or SERIAL8 column). If the table does not contain a SERIAL or SERIAL8 column, the methods return 0. If you assign a new serial starting number, the methods return that number.

You must cast the Statement or PreparedStatement object to IfxStatement, the Informix-specific implementation of the Statement interface, if you want to use the getSerial() and getSerial8() methods. The following example shows how to perform the cast:

If you want to insert consecutive serial values into a column of data type SERIAL or SERIAL8, specify a value of 0 for the SERIAL or SERIAL8 column in the INSERT statement. When the column is set to 0, the database server assigns the next highest value.

For more detailed information about the Informix SERIAL and SERIAL8 data types, refer to Informix Guide to SQL: Reference and Informix Guide to SQL: Syntax. You can find the on-line version of both of these guides at the following Web site:

Obtaining Driver Version Information

There are two ways to obtain version information about Informix JDBC Driver: from your Java program or from the UNIX or Windows command line. The command line method also allows you to obtain the serial number you provided when you installed the driver on your computer.

To get version information from your Java program

    1. Import the Informix-specific package com.informix.jdbc.* into your Java program by adding the following line to the import section:

    2. Invoke the static method IfxDriver.getJDBCVersion(). This method returns a String object that contains the complete version of the current Informix JDBC Driver.

    An example of a version of Informix JDBC Driver is 1.22.JC1.

Important: For Version 1.22 of Informix JDBC Driver, the JDBC API methods Driver.getMajorVersion() and DatabaseMetaData.getDriverMajorVersion() always return the value 1. Similarly, the methods Driver.getMinorVersion() and DatabaseMetaData.getDriverMinorVersion() always return the value 22.
To get the version of Informix JDBC Driver from the command line, type the following command at the UNIX shell prompt or the Windows command prompt:

The command will also return the serial number you provided when you installed the driver. An example of a serial number is INF#J031093.




Informix JDBC Driver Programmer's Guide, Version 1.22
Copyright © 1998, Informix Software, Inc. All rights reserved.