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