DB2: Embedded SQL for Java (SQLJ) |
This will walk you through "compiling" an embedded SQL Java program. See the directories
for examples and compilation instructions for Java. See below for another embedded SQL Java program (that is, a SQLJ program). To get a better overview and rationnal of the steps to pre-compile, bind, and compile an embedded SQL program, look over the guide for embedded SQL C anc C++ programs. Here, I shall just give instructions how to do the equivalent for embedded SQL Java programs. Also, the procedure for Java is not nearly as clear as for C/C++. (Isn't it always like that with Java?!) |
First things first. To bind, compile, and later run your Java APPs, you will need to log onto one of the machines sen01 through sen20 or dem01 through dem23 in the ARIEL laboratory. The machine ella will not work. I repeat, the machine ella will not work. (Read on and you will learn why.)
If all went well, you now have a working executable APP. To run your Java APP say
Again, you will undoubtably need urun as Java is such an amazing resource hog. |
Here is an example embedded SQL Java program. It does not do much, but is instructive. It does the same thing as the example C program in the embedded SQL C guide. Try pre-compiling / compiling it. Use the database c3421a00 for this. It does not matter if you are in one of the other sections (section B / c3421b00); you can use c3421a00 for trying this. The APP queries a table sailor in schema techstu. User techstu has granted select privileges to all on table sailor, so the bind step will be legal.
The instance of the table sailor at the time of writing is
SNAME SID RATING AGE --------------- ----------- ------ ------ yuppy 22 1 20 lubber 31 1 25 guppy 44 2 31 rusty 58 3 47 So once you have a clean compile, if you ask for example
you should get the response
Do not forget to check out some of the other sample programs found in
|