Java and SQLJ Versus PL/SQL
Total Page:16
File Type:pdf, Size:1020Kb
Oracle8i SQLJ Developer’s Guide and Reference Release 3 (8.1.7) July 2000 Part No. A83723-01 SQLJ Developer’s Guide and Reference, Release 3 (8.1.7) Part No. A83723-01 Copyright © 1996, 1999, 2000 Oracle Corporation. All rights reserved. Primary Author: Brian Wright Contributing Author: Ekkehard Rohwedder Contributors: Brian Becker, Alan Thiesen, Lei Tang, Julie Basu, Pierre Dufour, Jerry Schwarz, Risto Lankinen, Cheuk Chau, Vishu Krishnamurthy, Rafiul Ahad, Jack Melnick, Tim Smith, Thomas Pfaeffle, Tom Portfolio, Ellen Barnes, Susan Kraft, Sheryl Maring, Angie Long The Programs (which include both the software and documentation) contain proprietary information of Oracle Corporation; they are provided under a license agreement containing restrictions on use and disclosure and are also protected by copyright, patent, and other intellectual and industrial property laws. Reverse engineering, disassembly, or decompilation of the Programs is prohibited. The information contained in this document is subject to change without notice. If you find any problems in the documentation, please report them to us in writing. Oracle Corporation does not warrant that this document is error free. Except as may be expressly permitted in your license agreement for these Programs, no part of these Programs may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Oracle Corporation. If the Programs are delivered to the U.S. Government or anyone licensing or using the programs on behalf of the U.S. Government, the following notice is applicable: Restricted Rights Notice Programs delivered subject to the DOD FAR Supplement are "commercial computer software" and use, duplication, and disclosure of the Programs, including documentation, shall be subject to the licensing restrictions set forth in the applicable Oracle license agreement. Otherwise, Programs delivered subject to the Federal Acquisition Regulations are "restricted computer software" and use, duplication, and disclosure of the Programs shall be subject to the restrictions in FAR 52.227-19, Commercial Computer Software - Restricted Rights (June, 1987). Oracle Corporation, 500 Oracle Parkway, Redwood City, CA 94065. The Programs are not intended for use in any nuclear, aviation, mass transit, medical, or other inherently dangerous applications. It shall be the licensee's responsibility to take all appropriate fail-safe, backup, redundancy, and other measures to ensure the safe use of such applications if the Programs are used for such purposes, and Oracle Corporation disclaims liability for any damages caused by such use of the Programs. Oracle is a registered trademark, and JDeveloper ™, Net8 ™, Oracle Objects ™, Oracle8 i™, Oracle8 ™, Oracle7 ™, Oracle Lite ™, PL/SQL ™, Pro*C ™, SQL*Net®, and SQL*Plus® are trademarks or registered trademarks of Oracle Corporation. All other company or product names mentioned are used for identification purposes only and may be trademarks of their respective owners. Contents Send Us Your Comments .................................................................................................................. xv Preface......................................................................................................................................................... xvii Intended Audience ............................................................................................................................. xvii Document Structure ........................................................................................................................... xviii Document Conventions ....................................................................................................................... xx Related Documents.............................................................................................................................. xxi 1 Overview Introduction to SQLJ.......................................................................................................................... 1-2 Basic Concepts............................................................................................................................... 1-2 Java and SQLJ versus PL/SQL ................................................................................................... 1-3 Overview of SQLJ Components ...................................................................................................... 1-5 SQLJ Translator and SQLJ Runtime........................................................................................... 1-5 SQLJ Profiles.................................................................................................................................. 1-6 Overview of Oracle Extensions to the SQLJ Standard ................................................................ 1-8 Basic Translation Steps and Runtime Processing......................................................................... 1-9 Translation Steps .......................................................................................................................... 1-9 Summary of Translator Input and Output ............................................................................. 1-11 Runtime Processing.................................................................................................................... 1-14 Alternative Deployment Scenarios ............................................................................................... 1-16 Running SQLJ in Applets .......................................................................................................... 1-16 Introduction to SQLJ in the Server........................................................................................... 1-19 Using SQLJ with an Oracle Lite Database .............................................................................. 1-20 iii Alternative Development Scenarios ............................................................................................. 1-23 SQLJ NLS Support ...................................................................................................................... 1-23 SQLJ in JDeveloper and Other IDEs ........................................................................................ 1-23 Windows Considerations .......................................................................................................... 1-24 2 Getting Started Assumptions and Requirements...................................................................................................... 2-2 Assumptions About Your Environment ................................................................................... 2-2 Requirements for Using Oracle SQLJ ........................................................................................ 2-2 Supported JDK Versions.............................................................................................................. 2-4 JServer Configuration................................................................................................................... 2-4 Checking the Installation and Configuration ............................................................................... 2-6 Check for Installed Directories and Files .................................................................................. 2-6 Set the PATH and CLASSPATH ................................................................................................ 2-6 Verify Installation of sqljutl Package ......................................................................................... 2-8 Testing the Setup................................................................................................................................. 2-9 Set Up the Runtime Connection ................................................................................................. 2-9 Create a Table to Verify the Database...................................................................................... 2-10 Verify the JDBC Driver .............................................................................................................. 2-11 Verify the SQLJ Translator and Runtime ................................................................................ 2-11 Verify the SQLJ Translator Connection to the Database....................................................... 2-12 3 Basic Language Features Overview of SQLJ Declarations....................................................................................................... 3-2 Rules for SQLJ Declarations ........................................................................................................ 3-2 Iterator Declarations..................................................................................................................... 3-3 Connection Context Declarations............................................................................................... 3-4 Declaration IMPLEMENTS Clause ............................................................................................ 3-5 Declaration WITH Clause............................................................................................................ 3-6 Overview of SQLJ Executable Statements..................................................................................... 3-9 Rules for SQLJ Executable Statements......................................................................................