Many programming books introduce new languages using a variation of the "Hello World" program. The classic "Hello World" program has a simple objective: to display the words "Hello World" on the screen. My version of "Hello World" uses SQLJ statements to connect to the database and retrieve the current date, which is then displayed on the screen. First, I'll show you the code required for this "Hello World" program; then I'll show how to compile and run it. By convention, SQLJ programs use the file extension .sqlj, so the "Hello World" program will be named HelloWorld.sqlj.
The HelloWorld.sqlj program, shown in Example 1-1, performs the following tasks:
Connects to the database.
Retrieves the current date from the database.
Displays a message containing the current date obtained in the previous step.
Disconnects from the database.
/* The program HelloWorld.sqlj illustrates how to connect to a database, and display the words "Hello World" along with the current date. */ // import required packages import java.sql.Date; import java.sql.SQLException; import oracle.sqlj.runtime.Oracle; public class ...