Product Documentation

FairCom Java Stored Procedures

Previous Topic

Next Topic

Quick Start - Java Development

This Quick Start for Java stored procedures includes four simple tutorials. Four SQL scripts have been included in the SQL Stored Procedures Tutorial directory, located in:

drivers\java.sql.storedprocs\tutorials

Java Requirements for Stored Procedures

Note: The FairCom DB SQL Java Stored Procedure and Trigger support requires a Java Development Kit (JDK) be installed on your computer. A Java Runtime Environment (JRE) is not sufficient. FairCom DB V11.5 (c-treeRTG and FairCom Edge V2.5) and later require JDK V1.7 or newer.

Note: For the tutorials to work correctly, the three Java-related “SETENV” lines in your <faircom>/config/ctsrvr.cfg file need to be active (the lines are not commented out with leading semicolons), the lines are all set to paths that are valid on your computer, and there is no whitespace before or after the "=" sign. Here are some typical examples, which will need to be adjusted for your machine:

Microsoft Windows

; JDK environment settings - Be sure to set the JDK to your version.

SETENV CLASSPATH=C:\Program Files\Java\jdk1.7.0_75\jre\lib\rt.jar;.\classes\ctreeSQLSP.jar

SETENV JVM_LIB=C:\Program Files\Java\jdk1.7.0_75\jre\bin\server\jvm.dll

SETENV JAVA_COMPILER=C:\Program Files\Java\jdk1.7.0_75\bin\javac.exe

Linux

; JDK environment settings - Be sure to set the JDK to your version.

SETENV CLASSPATH=/usr/java/jdk1.7.0_75/jre/lib/rt.jar:./classes/ctreeSQLSP.jar

SETENV JAVA_COMPILER=/usr/java/jdk1.7.0_75/bin/javac

SETENV JVM_LIB=/usr/java/jdk1.7.0_75/jre/lib/amd64/server/libjvm.so

The lines above all need to correctly point to your JDK installation folder before you start the c-tree server, because changes to ctsrvr.cfg take effect only when you launch the c-tree server.

All of these Java-related lines should point at files which are in the same JDK folder (“jdk1.7.0_75” in this example), and not from a JRE installation. Violating these rules can result in problems that can be difficult to track down.

In the CLASSPATH line, the path to ctreeSQLSP.jar is relative to the “server” folder. On Linux, the entries in the CLASSPATH line should be separated with colons instead of semicolons.

The purpose of these three lines is to give the c-tree server the information it needs to compile and run Java source code. This is because the stored procedures demonstrated by this tutorial are written in Java.

If you are using c-treeRTG or FairCom Edge, adjust the path to match your product.

Executing the Tutorials

These samples consist of four SQL Scripts. To execute these SQL scripts we will use the FairCom DB Interactive SQL utility (isql) or FairCom DB SQL Explorer:

Overview

The FairCom DB SQL stored procedures and triggers support provide the ability to write Java routines that contain SQL statements and store those routines with a database under the FairCom DB SQL Server. Tools and applications can then execute the procedures.

trigger architecture

A stored procedure is a snippet of Java code embedded in a SQL CREATE PROCEDURE statement. The Java snippet can use all standard Java features as well as use the supplied Java classes for processing SQL statements.

NetBeans Plugin for Java Stored Procedure Development

c-treeACE SQL now includes a Java NetBeans plugin for advanced development potential. Take advantage of the complete NetBeans IDE in creating and maintaining new and existing Java stored procedures. Existing Java stored procedure investments can continue to be used with much easier maintenance and deployment capabilities.

In This Chapter

Command Line Execution Using Interactive SQL - Windows

GUI Execution Using FairCom DB SQL Explorer - Windows

Command-Line Execution Using Interactive SQL - Linux

NetBeans Plugin for Java Stored Procedure Development

TOCIndex