Introduction to HCL Informix® embedded SQLJ
This chapter explains what you can do with Informix® Embedded SQLJ and provides an overview of how embedded SQLJ works.
What is embedded SQLJ?
- The SQLJ translator, which translates SQLJ code into Java™ code
- A set of Java™ classes that provide runtime support for SQLJ programs
Informix® Embedded SQLJ includes the standard SQLJ implementation, as defined by the SQLJ consortium, plus specific Informix® extensions. The rest of this manual refers to Informix® Embedded SQLJ as Embedded SQLJ. The standard SQLJ implementation is referred to as traditional Embedded SQLJ.
How does embedded SQLJ work?
When you use Embedded SQLJ, you embed SQL statements in your Java™ source code. You use the SQLJ translator to convert the embedded SQL statements to Java™ source code with calls to JDBC. JDBC is the JavaSoft specification of a standard application programming interface (API) that allows Java™ programs to access database management systems.
See the Informix® JDBC Driver Programmer's Guide for information about using the Informix® JDBC Driver.
Embedded SQLJ versus JDBC
Embedded SQLJ does not support dynamic SQL; you must use the JDBC API if you want to use dynamic SQL. Your Embedded SQLJ program can call the JDBC API to perform a dynamic operation (the SQLJ connection-context object that you use to connect an Embedded SQLJ program to the database contains a JDBC Connection object that you can use to create JDBC statement objects).
- Default connection context. You only need to set the default connection context once within a program; then every subsequent Embedded SQLJ statement uses this connection context unless you specify otherwise.
- Reduced statement complexity. For example, you do not need to explicitly bind each variable; Embedded SQLJ performs binding for you. Generally, this feature allows you to create smaller programs than with the JDBC API.
- Compile-time syntax and semantics checking. The Embedded SQLJ translator checks the syntax of SQL statements.
- Compile-time type checking. The Embedded SQLJ translator and the Java™ compiler check that the Java™ data types of arguments are compatible with the SQL data types of the SQL operation.
- Compile-time schema checking. You can connect to a sample database schema during translation to check that your program uses valid SQL statements for the tables, views, columns, stored procedures, and so on in your sample.