/* WARNING: This file contains a bug that will result in a runtime error if it is not corrected. The bug has been intentionally added to demonstrate online checking capabilities during translate time. */ import java.sql.SQLException ; import oracle.sqlj.runtime.Oracle; // iterator for the select #sql iterator MyCheckedIter (String ITEM_NAME); class TestInstallSQLJChecker { //Main method public static void main (String args[]) { try { /* if you're using a non-Oracle JDBC Driver, add a call here to DriverManager.registerDriver() to register your Driver */ /* This call sets up the default SQLJ connection context, which establishes a connection to the database. */ Oracle.connect(TestInstallSQLJChecker.class, "connect.properties"); TestInstallSQLJChecker ti = new TestInstallSQLJChecker(); ti.runExample(); } catch (SQLException e) { System.err.println("Error running the example: " + e); } } //End of method main //Method that runs the example void runExample() throws SQLException { //Issue SQL command to clear the SALES table #sql { DELETE FROM SALES }; #sql { INSERT INTO SALES(ITEM_NAME) VALUES ('Hello, SQLJ Checker!')}; /* Note that the select list contains an invalid column name (it should be ITEM_NAME). Using a database connection at translation time will flag this problem. */ MyCheckedIter iter; #sql iter = { SELECT ITEM_NAMAE FROM SALES }; while (iter.next()) { System.out.println(iter.ITEM_NAME()); } } }