Scalable Database Server, HiRDB Version 8 UAP Development Guide

[Contents][Index][Back][Next]

18.1.1 What is SQLJ?

SQLJ is a language specification for coding a static SQL statement as an embedded SQL statement in Java and executing it.

Figure 18-1 shows the flow of UAP development that uses SQLJ.

Figure 18-1 Flow of UAP development that uses SQLJ

[Figure]

SQLJ consists of SQLJ Translator and SQLJ Runtime Library.

SQLJ Translator
SQLJ Translator analyzes an SQLJ source program and replaces SQL statements with standard Java instructions for accessing a database through SQLJ Runtime Library.
SQLJ Translator generates a Java source file and a profile that stores SQL information. The user uses the Java compiler to compile the Java source file to create a class file (executable file).

SQLJ Runtime Library
SQLJ Runtime Library is used for executing a compiled class file.
SQLJ Runtime Library can be used in either of the following ways, depending on the access interface used:
  • Invoke the JDBC interface API (standard interface version) and execute the SQL statements.
  • Invoke an original interface (native interface version), not the JDBC interface, and execute the SQL statements.

Figure 18-2 shows UAP execution using SQLJ.

Figure 18-2 Execution of a UAP that uses SQLJ

[Figure]

Explanation:
  • A class file of the SQLJ source file compiled by the Java compiler accesses a database through the SQLJ Runtime Library.
  • When the native interface is used, SQLJ Runtime Library directly invokes a HiRDB client library instead of invoking JDBC. In this case, you cannot use coding that directly invokes the JDBC API and shares connection and result sets with JDBC.
  • Because the SQLJ Runtime Library loads a profile during execution, the class file and profile must be stored in the same directory. Also, when the class file is stored in the jar file, you must also store the profile in the jar file.