SQLJ is a now obsolete working title for aspirations, Java and SQL merge. SQLJ Part 0 defines the ability to embed SQL statements in Java programs. Part 0 has now taken over 9075 of the database language SQL as part of 10 Object Language Bindings ( SQL / OLB) of ISO / IEC. Parts 1 and 2 describe the opposite way, namely Java classes ( Routines and Types) to address in SQL statements. Part 1 and 2 were standardized as part of SQL 13 SQL Routines and Types Using the Java Programming Language in SQL.
Hereinafter, the term is a synonym for SQLJ SQLJ Part 0
With SQLJ Embedded SQL is defined for Java. In contrast, a JDBC API.
The embedded SQL statements have the following format:
# sql [ [
Pros and Cons
SQLJ offers several advantages:
- Programming is much easier compared to JDBC, SQLJ as can directly access variables of the surrounding Java code.
- In the case of SQLJ for IBM DB2 is a better authentication control because user rights are checked on the basis of tables, but based on bonded SQLJ profiles (packages), so that is a program-based authorization possible.
- The SQLJ translator checks the syntax and semantics of SQL statements. There is the possibility the statements against the database schema to check with SQL errors can be detected and remedied in good time. In contrast, errors are detected at runtime when using JDBC.
- SQLJ programs must be transformed by means of a preprocessor in Java source code
- SQLJ syntax is not recognized by many development environments
- SQLJ is not supported by common persistence frameworks like Hibernate
- The preprocessor understands As of early 2006, no elements of the Java syntax with versions 1.4 ( assert ) and 5.0 ( Generic Types, Extended For Loop, among others) have been introduced.
- The preprocessor loads may classes, upon which the translatable class. This class initializer should be executed, which may Side effects causes or increases the translation time.
Examples and comparison with JDBC
The following examples compare SQLJ syntax with JDBC calls:
- IBM Redbook: DB2 for z / OS and OS/390: Ready for Java
- Database language
- Java ( programming language)