SQLJ Statements and the SQLJ Translator

To use SQLJ, we embed SQLJ statements directly in our Java code. SQLJ statements are not valid Java source code, however, so we need to distinguish between SQLJ files and Java files. We do this by naming our SQLJ files with a .sqlj suffix. Then, instead of compiling them with the javac compiler, we need to process them with the SQLJ translator.

Normally, the SQLJ compiler does two things for you: It interprets the SQLJ file and creates a valid Java source file—a .java file—from it, then compiles the Java source file into an executable class file. The process is illustrated in Figure 7-1.

Figure 7-1. SQLJ compilation.

Connecting with SQLJ

Two things are required for a program to connect to a database using ...

Get Java™ Oracle® Database Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.