INFORMIX
IBM Informix Embedded SQLJ User's Guide
Chapter 3: Building an Embedded SQLJ Program
Contents Index

A Simple Embedded SQLJ Program

This 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 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.




IBM Informix Embedded SQLJ User's Guide, Version 1.0
Copyright © 1999, IBM Corporation. All rights reserved.