Oracle8i SQLJ Developer's Guide and Reference Release 8.1.5 A64684-01 |
|
This section contains samples that run in the server. The demo in this section is located in the following directory:
[Oracle Home]/sqlj/demo/server
This example demonstrates a SQLJ application that runs in the embedded Java VM of the Oracle8i server.
Before trying to run this server-side demo application, refer to README.txt
in the following directory:
[Oracle Home]/sqlj/demo/server
//---------------- Start of file ServerDemo.sqlj ----------------
import java.sql.Date;
import java.sql.SQLException;
class ServerDemo
{
public static void main (String argv[])
{
// Note: No explicit connection handling is required
// for server-side execution of SQLJ programs.
try {
putLine("Hello! I'm SQLJ in server!");
Date today;
#sql {select sysdate into :today from dual};
putLine("Today is " + today);
putLine("End of SQLJ demo.");
} catch (Exception e) {
putLine("Error running the example: " + e);
}
}
static void putLine(String s) {
try {
#sql { call dbms_output.put_line(:s)};
} catch (SQLException e) {}
}