testinstallsqljchecker.sqlj
来自「orale培训教材包括了所有的sql说明和实例」· SQLJ 代码 · 共 57 行
SQLJ
57 行
/*首先启动oracle,listnner,并测试连接串ora8正常*/
/*
*test sqlj :insert into table: sales
*/
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
{
/* 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);
}
finally
{
try { Oracle.close(); } catch (SQLException 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 :HERE INSERT A RECORD
*/
MyCheckedIter iter;
#sql iter = { SELECT ITEM_NAME FROM SALES };
while (iter.next()) {
System.out.println(iter.ITEM_NAME());
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?