Stored Procedures in Java (Spjs) Guide Version 1.3.0 Table of Contents
Total Page:16
File Type:pdf, Size:1020Kb
Stored Procedures in Java (SPJs) Guide Version 1.3.0 Table of Contents 1. About This Document . 5 1.1. Intended Audience . 5 1.2. Document Organization . 5 1.3. New and Changed Information . 6 1.4. Notation Conventions . 6 1.5. Comments Encouraged . 9 2. Introduction . 10 2.1. What Is an SPJ? . 10 2.2. Benefits of SPJs . 10 2.2.1. Java Methods Callable From SQL . 11 2.2.2. Common Packaging Technique . 11 2.2.3. Security . 11 2.2.4. Increased Productivity . 11 2.2.5. Portability . 12 2.3. Use SPJs . 13 3. Get Started . 16 3.1. Required Client Software . 16 3.1.1. Java Development Kit . 16 3.2. Recommended Client Software . 17 3.2.1. Trafodion Command Interface (trafci) . 17 3.2.2. HP JDBC Type 4 Driver . 17 4. Develop SPJ Methods . 18 4.1. Guidelines for Writing SPJ Methods . 18 4.1.1. Signature of the Java Method . 18 4.1.2. Returning Output Values From the Java Method . 20 4.1.3. Returning Stored Procedure Result Sets . 21 4.1.4. Using the main() Method . 23 4.1.5. Null Input and Output . 24 4.1.6. Static Java Variables . 24 4.1.7. Nested Java Method Invocations . 24 4.2. Accessing Trafodion . 25 4.2.1. Use of java.sql.Connection Objects . 25 4.2.2. Using JDBC Method Calls . 27 4.2.3. Referring to Database Objects in an SPJ Method . 28 4.2.4. Using the SESSION_USER or CURRENT_USER Function in an SPJ Method . 30 4.2.5. Exception Handling . 33 4.3. Handling Java Exceptions . 34 4.3.1. User-Defined Exceptions . 34 4.4. Compiling and Packaging Java Classes . 35 5. Deploy SPJ JAR Files . 36 5.1. Create a Library . 37 5.2. Drop a Library . 39 5.3. Display Libraries . 40 6. Create SPJs . 41 6.1. Create a Procedure . 41 6.1.1. Create Procedure Settings . 41 6.2. Understand External Security . 50 6.3. Drop a Procedure . 51 6.4. Display Procedures and Their Properties . 52 7. Grant Privileges . 53 7.1. Granting Execute Privileges on an SPJ . ..