Home

 

Examining the generated SQLJ file

Before testing the SQLJ program, let us examine the generated SQLJ file:

The establishConnection method creates the database connection.

The execute method executes the SQL query and stores the result set in a cache. The SQLJ statement is embedded in this method (Example | 1-4):

Example 11-4 Embedded SQLJ

#sql [ctx] cursor1 = {SELECT ITSO.CUSTOMER.TITLE,
	    ITSO.CUSTOMER.FIRST_NAME, ITSO.CUSTOMER.LAST_NAME, ITSO.ACCOUNT.ID,
	    ITSO.ACCOUNT.BALANCE FROM ITSO.CUSTOMER JOIN ITSO.ACCOUNT_CUSTOMER
	    ON ITSO.CUSTOMER.SSN = ITSO.ACCOUNT_CUSTOMER.CUSTOMER_SSN JOIN
	    ITSO.ACCOUNT ON ITSO.ACCOUNT_CUSTOMER.ACCOUNT_ID = ITSO.ACCOUNT.ID
	    WHERE ITSO.ACCOUNT.BALANCE >= :BALANCE ORDER BY BALANCE DESC};

The next method moves to the next row of the result set if one exists.

The close method commits changes and closes the connection.

The corresponding setter and getter methods for the table fields in the database are also generated. You can use the getter methods to retrieve the columns in a row.
ibm.com/redbooks