sqlj - SQLJ translator

The sqlj command translates an SQLJ source file into a Java™ source file and zero or more SQLJ serialized profiles. By default, the sqlj command also compiles the Java source file.

Authorization

None

Command syntax

Read syntax diagramSkip visual syntax diagramsqlj-help-dir= directory-d= directory-props= properties-file-compile=true-compile=false-linemap=NO-linemap=YES-smap=NO-smap=YES-encoding= encoding-db2optimize-ser2class-status-version-C-help-C compiler-option-J JVM-option SQLJ-source-file-name

Command parameters

-help
Specifies that the SQLJ translator describes each of the options that the translator supports. If any other options are specified with -help, they are ignored.
-dir=directory
Specifies the name of the directory into which SQLJ puts .java files that are generated by the translator and .class files that are generated by the compiler. The default is the directory that contains the SQLJ source files.
The translator uses the directory structure of the SQLJ source files when it puts the generated files in directories. For example, suppose that you want the translator to process two files:
  • file1.sqlj, which is not in a Java package
  • file2.sqlj, which is in Java package sqlj.test
Also suppose that you specify the parameter -dir=/src when you invoke the translator. The translator puts the Java source file for file1.sqlj in directory /src and puts the Java source file for file2.sqlj in directory /src/sqlj/test.
-d=directory
Specifies the name of the directory into which SQLJ puts the binary files that are generated by the translator and compiler. These files include the .ser files, the name_SJProfileKeys.class files, and the .class files that are generated by the compiler.

The default is the directory that contains the SQLJ source files.

The translator uses the directory structure of the SQLJ source files when it puts the generated files in directories. For example, suppose that you want the translator to process two files:
  • file1.sqlj, which is not in a Java package
  • file2.sqlj, which is in Java package sqlj.test
Also suppose that you specify the parameter -d=/src when you invoke the translator. The translator puts the serialized profiles for file1.sqlj in directory /src and puts the serialized profiles for file2.sqlj in directory /src/sqlj/test.
-compile=true|false
Specifies whether the SQLJ translator compiles the generated Java source into bytecodes.
true
The translator compiles the generated Java source code. This is the default.
false
The translator does not compile the generated Java source code.
-linemap=no|yes
Specifies whether line numbers in Java exceptions match line numbers in the SQLJ source file (the .sqlj file), or line numbers in the Java source file that is generated by the SQLJ translator (the .java file).
no
Line numbers in Java exceptions match line numbers in the Java source file. This is the default.
yes
Line numbers in Java exceptions match line numbers in the SQLJ source file.
-smap=no|yes
Specifies whether the SQLJ translator generates a source map (SMAP) file for each SQLJ source file. An SMAP file is used by some Java language debug tools. This file maps lines in the SQLJ source file to lines in the Java source file that is generated by the SQLJ translator. The file is in the Unicode UTF-8 encoding scheme. Its format is described by Original Java Specification Request (JSR) 45, which is available from this web site:
http://www.jcp.org
no
Do not generated SMAP files. This is the default.
yes
Generate SMAP files. An SMAP file name is SQLJ-source-file-name.java.smap. The SQLJ translator places the SMAP file in the same directory as the generated Java source file.
-encoding=encoding-name
Specifies the encoding of the source file. Examples are JIS or EUC. If this option is not specified, the default converter for the operating system is used.
-db2optimize
Specifies that the SQLJ translator generates code that enables SQLJ context caching in a WebSphere® Application Server environment for applications that run against Db2® data servers.

-db2optimize causes a user-defined context to extend a custom driver class, which enables context caching and connection caching in WebSphere Application Server.

Because context caching is enabled by using an instance of IBM® Data Server Driver for JDBC and SQLJ class sqlj.runtime.ref.DefaultContext, db2jcc4.jar must be in the CLASSPATH when you translate and compile the Java application.

You cannot use connection sharing in WebSphere Application Server if you use context caching.

Important: Context caching that is enabled by the -db2optimize option can provide performance benefits over connection pooling and statement pooling that is provided by WebSphere Application Server. However, context caching can result in significant resource consumption in the application server, and might have unintended side effects if it is not used correctly. For example, if two applications use an SQLJ profile with the same name, they might overwrite each other, because both use sqlj.runtime.ref.DefaultContext. Use context caching only if:
  • The system is not storage-constrained.
  • Cached statements are often reused on the same Connection.
  • All applications have distinct names for their SQLJ profiles.
-ser2class
Specifies that the SQLJ translator converts .ser files to .class files.
-status
Specifies that the SQLJ translator displays status messages as it runs.
-version
Specifies that the SQLJ translator displays the version of the IBM Data Server Driver for JDBC and SQLJ. The information is in this form:
IBM SQLJ xxxx.xxxx.xx
-C-help
Specifies that the SQLJ translator displays help information for the Java compiler.
-Ccompiler-option
Specifies a valid Java compiler option that begins with a dash (-). Do not include spaces between -C and the compiler option. If you need to specify multiple compiler options, precede each compiler option with -C. For example:
-C-g -C-verbose
All options are passed to the Java compiler and are not used by the SQLJ translator, except for the following options:
-classpath
Specifies the user class path that is to be used by the SQLJ translator and the Java compiler. This value overrides the CLASSPATH environment variable.
-sourcepath
Specifies the source code path that the SQLJ translator and the Java compiler search for class or interface definitions. The SQLJ translator searches for .sqlj and .java files only in directories, not in JAR or zip files.
-JJVM-option
Specifies an option that is to be passed to the Java virtual machine (JVM) in which the sqlj command runs. The option must be a valid JVM option that begins with a dash (-). Do not include spaces between -J and the JVM option. If you need to specify multiple JVM options, precede each compiler option with -J. For example:
-J-Xmx128m -J-Xmine2M
SQLJ-source-file-name
Specifies a list of SQLJ source files to be translated. This is a required parameter. All SQLJ source file names must have the extension .sqlj.

Output

For each source file, program-name.sqlj, the SQLJ translator produces the following files:
  • The generated source program

    The generated source file is named program-name.java.

  • A serialized profile file for each connection context class that is used in an SQLJ executable clause
    A serialized profile name is of the following form:
    program-name_SJProfileIDNumber.ser
  • If the SQLJ translator invokes the Java compiler, the class files that the compiler generates.

Examples

   sqlj -encoding=UTF8 -C-O MyApp.sqlj