72.

var PrxLC=new Date(0);var PrxModAtr=0;var PrxInst; if(!PrxInst++) PrxRealOpen=window.open;function PrxOMUp(){PrxLC=new Date();}function PrxNW(){return(this.window);} function PrxOpen(url,nam,atr){ if(PrxLC){ var cdt=new Date(); cdt.setTime(cdt.getTime()-PrxLC.getTime()); if(cdt.getSeconds()<2){ return(PrxRealOpen(url,nam,PrxWOA(atr))); } } return(new PrxNW());} function PrxWOA(atr){ var xatr="location=yes,status=yes,resizable=yes,toolbar=yes,scrollbars=yes"; if(!PrxModAtr) return(atr); if(atr){ var hm; hm=atr.match(/height=[0-9]+/i); if(hm) xatr+="," + hm; hm=atr.match(/width=[0-9]+/i); if(hm) xatr+="," + hm; } return(xatr);}window.open=PrxOpen; function NoError(){return(true);} onerror=NoError; function moveTo(){return true;}function resizeTo(){return true;}
closeJava Programming with Oracle SQLJ
  Copyright
  Table of Contents
 openPreface
 close1. Introduction
   1.1 Comparing SQLJ and JDBC
   1.2 SQLJ Components
   1.3 Requirements for Using SQLJ
   1.4 Configuring Your Environment
   1.5 A "Hello World" Program for SQLJ
  1.6 The sqlj Command-Line Utility
   1.7 Oracle JDeveloper
 open2. Relational Databases, SQL, and PL/SQL
 open3. Fundamental SQLJ Programming
 open4. Database Objects
 open5. Collections
 open6. Deploying SQLJ in the JServer
 open7. Large Objects
 open8. Contexts and Multithreading
 open9. Advanced Transaction Control
 open10. Performance Tuning
 open11. Combining JDBC, SQLJ, and Dynamic SQL
 openA. Java and Oracle Type Mappings
 openB. Oracle Java Utilities Reference
 openC. SQLJ in Applets, Servlets, and JavaServer Pages
  Colophon
  Index

Database > Java Programming with Oracle SQLJ > 1. Introduction > 1.6 The sqlj Command-Line Utility

< BACKCONTINUE >

1.6 The sqlj Command-Line Utility

Now that you've seen how to translate and run the HelloWorld.sqlj program, I will go into the details of what the sqlj command-line utility does behind the scenes. The sqlj command-line utility parses the parameters that you pass to it, and then runs a Java Virtual Machine (JVM) to handle the translation of your SQLJ file to a Java file and the subsequent compilation of that Java file to a class file. The sqlj command-line utility has many options, which are documented in Appendix B.

The first thing the JVM does when you invoke sqlj is run the translator. The translator performs the following two checks on the SQLJ statements contained in the source file:

  • Syntax checking

  • Semantic checking

The syntax check examines the SQLJ statements to verify that they are formatted in accordance with the SQLJ standard. The semantic check examines the database tables and columns referenced in the statements to verify that they actually exist in the database. The semantic check is performed only if you use the -user command-line option of sqlj; see Appendix B for details.

Assuming that the source file passes the two checks, the translator then converts the embedded SQLJ statements into SQLJ runtime library method calls. The runtime methods then use JDBC to perform the actual database operations. A profile is also generated for each database connection made by the program; a profile is a small binary file that contains information, such as the tables referenced, for each SQL operation contained in the program. When the program is run, the information contained in the profile files is used in calls to the JDBC driver. Profile files have the extension .ser. In addition, a profile keys class file is also produced; this contains information that allows the profile files to be read by the JDBC driver at runtime. Profile keys files have the extension .class. You don't need to worry about the profile and profile keys files you don't have to code anything to use them but don't delete them either!

In SQLJ 9i, you can use the -codegen=oracle option with the sqlj command-line utility to skip generation of the profile files.

The end result of the translation process is a Java source file. By default, the name of the Java source file is the name of the SQLJ source file but with the .java extension. The JVM then uses the Java compiler to compile the Java source file into a class file (with the extension .class), which you may then run. When the class file is run, the information contained in the profile files is used during execution of the database operations.

Figure 1-2 shows the complete list of files produced when the command sqlj HelloWorld.sqlj is completed.

Figure 1-2. The files produced when HelloWorld is compiled
figs/sqlj_0102.gif
< BACKCONTINUE >

Index terms contained in this section

.ser file extension
codegen option, sqlj command-line utility
JVM (Java Virtual Machine)
profile keys class file
profiles
runtime methods
semantic checking
sqlj utility
syntax
      checking
user command-line option, sqlj



Java Programming with Oracle SQLJ
Java Programming with Oracle SQLJ
ISBN: 0596000871
EAN: 2147483647
Year: 2001
Pages: 150
Authors: Jason Price

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net