SQLJ is a language specification for coding a static SQL statement as an embedded SQL statement in Java and executing it.
The following figure shows the flow of UAP development when SQLJ is used.
Figure 19-1 Flow of UAP development that uses SQLJ
![[Figure]](FIGURE/ZU090250.GIF)
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 edition) and execute the SQL statements.
- Invoke an original interface (native interface edition), not the JDBC interface, and execute the SQL statements.
The following figure shows UAP execution when SQLJ is used.
Figure 19-2 Execution of a UAP that uses SQLJ
![[Figure]](FIGURE/ZU090260.GIF)
- 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.
All Rights Reserved. Copyright (C) 2011, Hitachi, Ltd.