Informix supports Java UDRs by running a Java Virtual Machine (JVM) in a named Virtual Processor class inside the server. So, in order to run any Java UDR, the first thing you need to do is to configure your server to include at least one instance of the "jvp" Virtual Processor class:
You can create a Java™ opaque type from an existing Java class that implements the SQLData interface.
1 Enable Java Virtual Processors
#Java Parameters VPCLASS jvp,num=1
In a production installation, where performance is important, you'll have more than one instance -- probably many more than one. But just one is probably adequate for development.
Notice that you will have other VPCLASS
entries for other processors. So your config may look like
VPCLASS cpu,num=3,noage VPCLASS jvp,num=1
2 Setup JVP variables
The following variables should be configured on database server instance.
Variable | Description | |
---|---|---|
JVPCLASSPATH
|
sets the CLASSPATH for the J/Foundation JAR files (krakatoa.jar and jdbc.jar) for the database server to use during startup | |
$INFORMIXDIR/extend/krakatoa /krakatoa.jar:$INFORMIXDIR/extend/krakatoa /jdbc.jar |
||
JVPHOME
|
The following is the directory where the J/Foundation classes and JDBC classes are installed | |
$INFORMIXDIR/extend/krakatoa
|
||
JVPLOGFILE
|
Java traces, output, and stack dumps are written to this file by the database server | |
$INFORMIXDIR/extend/krakatoa /jvp.log |
||
JVPPROPFILE
|
Optional properties file. Trace level settings, trace verbosity settings, monitor port, and a few other properties are set in this file. | |
$INFORMIXDIR/extend/krakatoa /.jvpprops |
||
JVPJAVAHOME
|
The directory where Java JRE is installed | |
$INFORMIXDIR/extend/krakatoa /jre |
||
JVPJAVAVM
|
The list of the JVM libraries that the database server loads. Unless you have very specific requirements, leave the default values | |
jsig;dbgmalloc;hpi;jvm;java;net;zip;jpeg | ||
JVPARGS
|
The settings for the JVM | |
-Dcom.ibm.tools.attach.enable=no;-Xms128m;-Xmx128m |
IBM® Informix 12.10.xC5 software supports Java Platform Standard Edition (Java SE), Version 7.
Informix installation applications install IBM Runtime Environment, Java Technology Edition, Version 7 on most platforms by default. That version is used to run Java user-defined routines that are created in the server.
To determine the installed JRE version:
$ onstat -g cfg | grep JVPJAVAHOME
$ /home/informix/extend/krakatoa/jre/bin/java -version
You can check your current setting by using onstat -g cfg command.
$ onstat -g cfg | grep JVP
3 Creating the JVP properties file
A JVP properties file contains property settings that control various runtime behaviors of the Java virtual processor.
The JVPPROPFILE
configuration parameter specifies the path to the properties file. When you initialize the database server,
the JVP initializes the environment based on the settings in the JVP property file.
The .jvpprops.template file in the $INFORMIXDIR/extend/krakatoa
directory documents the properties that you can set.
To prepare the JVP properties file:
- Copy the JVP properties template file, jvphome/.jvpprops.template into jvphome/.jvpprops where jvphome is the directory
$
INFORMIXDIR/extend/krakatoa
. - Edit .jvpprops to change the trace level or other properties if necessary.
- Set the
JVPPROPFILE
configuration parameter to jvphome/.jvpprops.
A sample properties file might contain the following items:
JVP.trace.settings:JVP=2 JVP.trace.verbose:1 JVP.trace.timestampformat:HH:MM JVP.splitLog:1000 JVP.monitor.port: 10000
The database server provides a fixed set of system trace events such as UDR sequence initialization, activation, and shutdown. You can also generate application-specific traces.
Look for extended log file under $INFORMIXDIR/tmp
directory (like tmp/jvp.log22).
4 Monitor Java Virtual Processors
$ onstat -g glo | grep jvp
5 Data types
The following table summarizes the mappings of DB2 or IBM Informix data types to Java data types for ResultSet.getXXX methods in JDBC programs, and for iterators in SQLJ programs. This table does not list Java numeric wrapper object types, which are retrieved using ResultSet.getObject.
Java data type | Database data type |
---|---|
short, java.lang.Short | SMALLINT |
short, java.lang.Short | BOOLEAN |
boolean, java.lang.Boolean | BOOLEAN |
int, java.lang.Integer | INTEGER |
int, java.lang.Integer | SERIAL |
long, java.lang.Long | INT8 |
long, java.lang.Long | BIGINT |
long, java.lang.Long | SERIAL8 |
long, java.lang.Long | BIGSERIAL |
float, java.lang.Float | SMALLFLOAT |
double, java.lang.Double | FLOAT |
java.math.BigDecimal | DECIMAL(p,s) |
java.math.BigDecimal | DECIMAL(p) |
java.math.BigDecimal | DECIMAL |
java.math.BigDecimal | MONEY(p,s) |
java.lang.String | CHAR(n) |
java.lang.String | NCHAR(n) |
java.lang.String | VARCHAR(m,r) |
java.lang.String | LVARCHAR(m,r) |
java.lang.String | NVARCHAR(m,r) |
java.lang.String | INTERVAL |
java.lang.String | CLOB |
byte[] | BYTE |
java.sql.Blob | BLOB |
java.sql.Clob | CLOB |
java.lang.Clob | TEXT |
java.sql.Date | DATE |
java.sql.Time | DATETIME HOUR TO SECOND |
java.sql.Timestamp | DATETIME YEAR TO FRACTION(5) |
java.io.ByteArrayInputStream | BLOB |
java.io.StringReader | CLOB |
java.io.ByteArrayInputStream | CLOB |