A simple embedded SQLJ program

The sample program Demo03.sqlj demonstrates the use of a named iterator to retrieve data from a database.

This simple program outlines a standard sequence for many Informix® Embedded SQLJ programs:

  1. Import necessary Java™ classes.
  2. Declare an iterator class.
  3. Define the main() method.

    All Java applications have a method called main, which is the entry point for the application (where the interpreter starts executing the program).

  4. Connect to the database.

    The constructor of the application makes the connection to the database by calling the initContext() method of the ConnectionManager class.

  5. Run queries.
  6. Create an iterator object and populate it by running a query.
  7. Handle the results.
  8. Close the iterator.

You can find the Demo03.sqlj sample program code in the $INFORMIXDIR/jdbc/demo/sqlj directory.