Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java Stored Procedures in DB2 for OS/390 Open, Portable Application Logic Julian Stuhler DB2/CICS/IMS GUIDE May 2000.

Similar presentations


Presentation on theme: "Java Stored Procedures in DB2 for OS/390 Open, Portable Application Logic Julian Stuhler DB2/CICS/IMS GUIDE May 2000."— Presentation transcript:

1 Java Stored Procedures in DB2 for OS/390 Open, Portable Application Logic Julian Stuhler DB2/CICS/IMS GUIDE May 2000

2 Topics  Introduction  Java Stored Procedures – An Overview  Environment Set-up  Developing & Testing JSPs  Usage Considerations  Summary

3 Introduction

4  DB2 consultant with Triton Consulting, based in the UK  14 years DB2 experience Database Administration Systems Programming Application Development  IBM Gold Consultant  Redbook – DB2 Network Computing Enhancements & Java Stored Procedures

5 JSPs – An Overview

6 What’s a Stored Procedure?  A program or routine executed by the database server in response to an SQL CALL statement issued by a client  Can receive and return parameters from / to calling client  Can enhance performance by replacing multiple SQL client calls  Can promote code re-use and consistency  Can improve security

7 Supported Languages  Can be written in a wide variety of languages Cobol C/C++ Assembler PL/1 REXX * PSM * Java * * Needs additional APAR support for V5 and V6

8 Java Stored Procedures  Prerequisites OS/390 Unix System Services (USS) OS/390 Recoverable Resource Services (RRS) and Workload Manager (WLM) DB2 For OS/390 V5 or V6 (with necessary additional APARs) Enterprise Toolkit for OS/390 (part of VisualAge for Java)  Features Open and fully portable code High Performance Java support JDBC (dynamic) and SQLJ (static) support

9 High Performance Java  HPJ compiler (part of ET/390) compiles Java into standard OS/390 machine code  Advantages Very high performance Retain code portability Allows WLM-managed stored procedures address space to run Java SPs without JVM support  Disadvantages More complex program preparation process

10 Java Terminology  Class Equivalent to a module in traditional programming  Method Equivalent to an entry point in traditional programming  Package A collection of related Java classes, “packaged” as a single unit Not to be confused with a DB2 package!

11 Environment Overview OS/390 USS Source Code Links Serialised Profiles WLM Executing SP DBRM Library Load Library

12 Runtime Environment

13 Environment Set-Up

14  Complex environment  Plenty of pre-requisites OS/390 DB2  Allow plenty of time to install all pre- requisites and get sample applications working  Good communications needed between DB2 and USS systems support staff

15 Set-Up Tasks - 1  Design library naming standards USS  High Performance Java (HPJ) libraries  SQLJ/JDBC libraries  Links directory  Serialised profiles directory OS/390  HPJ SQLJ load library  Application stored procedure load library  JAVAENV dataset  DBRM library

16 Set-Up Tasks - 2  Create.profile script Probably subsystem-specific  Set up new WLM environment for JSPs Needs RRS enabled  Create HPJ versions of JDBC/SQLJ drivers  Create JAVAENV dataset  Tailor SQLJ properties and cursor files, if necessary

17 Developing & Testing

18 Coding  Most standard Java constructs can be used  Special code needed for null handling E.g. to pass null input parameter from JDBC client to a stored procedure  Specific code to handle SQLJ iterators and result sets  Refer to SC26-9018, Application Programming Guide and Reference for Java

19 Program Prep - JDBC

20 Program Prep - SQLJ

21 Error Handling & Debugging  Include provision for passing back results from SP in return parameters Consider passing back meaningful message if problem encountered ( e.printStackTrace() )  As for other types of stored procedures, debugging can be a problem Output of Java println commands routed to JSPDEBUG in WLM SP JCL Stored Procedure Builder and ET/390 Debugger tool provide additional facilities

22 Usage Guidelines

23 Naming Issues  Source files One stored procedure (Java application class) per source file Source file named after DB2 SP name  Java package name One to one relationship with HPJ load module Use same name for PDS/E member name Group all related source files in single USS directory named after package  Many others to be considered Java class name, Java method, DB2 packages, JAR files, etc

24 DB2 Collections  Each SQLJ SP has 4 packages associated with it (one for each isolation level)  Collection containing these SPs must appear in package list for client issuing SP CALL  Use one collection for each Java package, with same name as the package  For JDBC, collection named in client’s package list must contain 4 generic JDBC packages Collection name must match Java package name

25 Case Sensitivity  Use upper case only for Java package names on S/390 Ditto for other environments if portability is important  JDBC or SQLJ Java client calling a stored procedure must code SP name in upper case  SQLJ stored procedure must refer to DB2 object names in upper case (else –204)

26 Packaging  Carefully consider number of SPs to group in a single Java package Large number will result in large HPJ load module for the package, which may need excessive WLM storage Small number will result in many DB2 collections to manage  Rules of thumb Group together small, frequently used SPs Keep larger SPs in their own Java package Package remainder along application lines

27 Portability  No code changes necessary to port JSP source files from one platform to another (e.g. Windows NT to OS/390)  Some changes may be required when porting client code Class.forName (name of driver to be loaded) Connection URL  Beware issues with ASCII/EBCDIC translation of Java curly brackets ({})

28 Performance  Significant overhead on first use of a given module Consider pre-staging critical modules and keeping them in storage Once in storage, performance on a par with other methods  Use different WLM application groups to correctly prioritise workload

29 Summary

30  JSPs for DB2 for OS/390 provide an open, scaleable, high-performance way of encoding an application’s business logic  Tread carefully in the short term; Complex environment set-up New application development skills DB2 code base still maturing

31 Questions?

32 For more information… Triton Consulting The Royal 25 Bank Plain Norwich NR2 4SF United Kingdom email:julian.stuhler@triton.co.uk http://www.triton.co.uk Tel:+44 (0) 870 2411550 Fax:+44 (0) 870 2411549


Download ppt "Java Stored Procedures in DB2 for OS/390 Open, Portable Application Logic Julian Stuhler DB2/CICS/IMS GUIDE May 2000."

Similar presentations


Ads by Google