SQLJ support
Db2 for z/OS includes SQLJ, which provides support for embedding static SQL statements in Java™ applications and servlets. Servlets are application programs that are written in Java and that run on a web server.
Because SQLJ coexists with JDBC, an application program can create a JDBC connection and then use that connection to run dynamic SQL statements through JDBC and embedded static SQL statements through SQLJ.
A group of companies that includes Oracle, Hewlett Packard, and IBM®, initially developed SQLJ to complement the dynamic SQL JDBC model with a static SQL model.
The SQLJ coding to update the salary of any employee is as follows:
#sql [myConnCtxt] { UPDATE EMP
SET SALARY = :newSalary
WHERE EMPNO = :empID };
By using SQLJ you gain the following advantages:
- Portable applications across platforms and database management systems.
- Strong typing, with compile and bind-time checking to ensure that applications are well designed for the database.
- Superior performance, manageability, and authorization checking of static SQL.
- Improved programmer productivity and easier maintenance. In comparison to a JDBC application, the resulting program is typically shorter and easier to understand.
- Familiarity for programmers who use embedded SQL in other traditional programming languages.