Web Thread
 All DB2 platforms


 Getting Started with
 Java and DB2 for z/OS
 and OS/390
Peggy Abelite
DB2 for z/OS and OS...
Agenda


          JDBC
          SQLJ
 Java Stored Procedures
New Java combined client



    International DB2 Users Gro...
Example customer e-business solutions
                    Unix
                  DB2
      Unix
                 Connect  ...
JDBC driver types - defined by Java (TM)
  Type 1 -- implements JDBC as a layer on top of ODBC
 Type 2 -- uses native meth...
JDBC Example -- Select

java.sql.PreparedStatement ps =
   con.prepareStatement( "SELECT ADDRESS FROM
EMP WHERE NAME=?");
...
JDBC Examples - Call a stored procedure
  CallableStatement cstmt = con.prepareCall(
            "CALL MYRES1(?)" );
  cst...
SQLJ Overview
Static SQL syntax for Java
  easier than JDBC, better performance too!
Wide DBMS vendor acceptance
  IBM, Or...
Why use SQLJ?
Static SQL performance for Java applications
  significant performance advantage over
  JDBC
Static SQL auth...
What does SQLJ support?
Static SQL
  INSERT, UPDATE, DELETE, CREATE,
  GRANT, etc.
  Singleton SELECT and cursor-based
  S...
Static SQL Authorization

Static SQL is associated with "program"
  plans/packages identify "programs" to DB2
  program au...
Retrieve a single row from DB2
SQLJ:
      #sql (con) { SELECT ADDRESS INTO :addr FROM EMP
                   WHERE NAME=:...
SQLJ example: INSERT one row

 SQLJ:
 #sql (con) {INSERT INTO T1 VALUES( :hv1, :hv2, :hv3) };
  JDBC:
    CallableStatemen...
Compiling an SQLJ application

SQLJ source                                                                                ...
Java API Performance Comparisons
                                600
                                                     ...
Java Stored Procedures
SQLJ Part 1 specification
  Output parameters are single-element arrays
   Because Java doesn't all...
V7: Built-in Utility Stored Procedures
 As per SQLJ specification
 Invoked with CALL statement
   INSTALL_JAR (file URL)
 ...
Tasks for OS/390 System Programmer
Set up WLM environment, address space
JCL
Install IBM S/390 JDK w/enhancement
Install J...
JAVAENV DD CARD
          (in WLM address space JCL)
Dataset containing RUNOPTS
  Applies to entire WLMENV, not individual...
Stored Procedure Performance by Language
Normalized Throughput - trans per second




                                    ...
What is DB2 Common Client?
Reengineering of DB2 Connect and CAE
                                            ?
            ...
Objectives for new Java Client
 Single driver for Unix, Windows, and
 OS/390
   eliminate major cause of Java porting
   p...
DB2 Java Client Architecture

                Common Code for all drivers:
                      JDBC APIs
               ...
New function in new Java Client

 Type 4 driver for thin clients
 Provide fully compliant JDBC 2.0 driver
 Trace improveme...
JCC: Type 4 Driver support
Configuration D
  Java
   program                  OS/390
                             DB2




...
DB2's type 4 JDBC driver
Targeted at clients that fit this profile:
  prefer to not install the JDBC driver on their machi...
New Java API Enhancements
Scrollable cursor support
Improved security for DB2
authentication
Java API for Set Client Infor...
Scrollable Cursor Support
-- Exploits DB2 engine scrolling
-- Supports update operations                     DB2 Server
--...
Java API for Set Client Information
For DB2 for Unix and Windows users:
 provides additional monitoring information
For DB...
Improved SQL Error Information
DB2Diagnosable class for reporting contents of
the SQLCA and SQL error message text
 getSQL...
Native DB2 Server SQL Error Messages

 "Error Message" stored procedures are
 provided by each DB2 server (including
 DB2 ...
SQLJ Application Development Process
(BIG improvements !)
100% Java application process
  eliminates DBRM files and .bnd f...
Summary

JDBC Driver Types
  Remember what Type 4 is designed for
SQLJ - static SQL for a dynamic world
Java stored proced...
Upcoming SlideShare
Loading in...5
×

Getting Started with Java and DB2 for z/OS and OS/390

1,583

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,583
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
42
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Getting Started with Java and DB2 for z/OS and OS/390

  1. 1. Web Thread All DB2 platforms Getting Started with Java and DB2 for z/OS and OS/390 Peggy Abelite DB2 for z/OS and OS/390 Development IBM Corporation September 3, 2002
  2. 2. Agenda JDBC SQLJ Java Stored Procedures New Java combined client International DB2 Users Group
  3. 3. Example customer e-business solutions Unix DB2 Unix Connect zSeries 900 A DB2 Connect OS/390 Unix DB2 C DB2 AIX Connect DB2 zSeries 900 Connect CICS OS/390 DB2 B IMS zSeries 900 WebSphere EE Linux OS/390 Linux Linux DB2 DB2 DB2 DB2 Connect Connect Connect Hipersockets and hypervisor International DB2 Users Group
  4. 4. JDBC driver types - defined by Java (TM) Type 1 -- implements JDBC as a layer on top of ODBC Type 2 -- uses native method calls (JNI) to call DLLs that issue the SQL (the DLLs are specially written for JDBC) Use Type 2 for local access (and transactional remote access) Type 3 -- network driver that is database vendor independent Type 4 -- network driver that speaks the database's native network protocol Use Type 4 for "network" access (non-transactional) International DB2 Users Group
  5. 5. JDBC Example -- Select java.sql.PreparedStatement ps = con.prepareStatement( "SELECT ADDRESS FROM EMP WHERE NAME=?"); ps.setString(1, name); java.sql.ResultSet names = ps.executeQuery(); names.next(); addr =names.getString(1); names.close(); International DB2 Users Group
  6. 6. JDBC Examples - Call a stored procedure CallableStatement cstmt = con.prepareCall( "CALL MYRES1(?)" ); cstmt.setBigDecimal(1, startSal); boolean rsltFlag = cstmt.execute(); if ( rsltFlag ) { queryBasic = cstmt.getResultSet(); while (queryBasic.next()) { name = queryBasic.getString(1); sal = queryBasic.getBigDecimal(2,2); System.out.println( name + " " + sal ); } queryBasic.close(); } International DB2 Users Group
  7. 7. SQLJ Overview Static SQL syntax for Java easier than JDBC, better performance too! Wide DBMS vendor acceptance IBM, Oracle, Sybase, Tandem... SQLJ has been accepted by ANSI for inclusion in the SQL-related standards www.sqlj.org International DB2 Users Group
  8. 8. Why use SQLJ? Static SQL performance for Java applications significant performance advantage over JDBC Static SQL authorization model provides Java with a stronger authorization model Productivity less code written by the application programmer resulting code is easier to maintain International DB2 Users Group
  9. 9. What does SQLJ support? Static SQL INSERT, UPDATE, DELETE, CREATE, GRANT, etc. Singleton SELECT and cursor-based SELECT calls to stored procedures (including result sets) COMMIT, ROLLBACK methods for CONNECT, DISCONNECT JDBC must be used for the dynamic SQL specs for portable Java stored procedures International DB2 Users Group
  10. 10. Static SQL Authorization Static SQL is associated with "program" plans/packages identify "programs" to DB2 program author's table privileges are used end users are granted EXECUTE on program Dynamic SQL is associated with "user" no notion of "program" end users must have table privileges BIG PROBLEM FOR A LARGE ENTERPRISE!!! International DB2 Users Group
  11. 11. Retrieve a single row from DB2 SQLJ: #sql (con) { SELECT ADDRESS INTO :addr FROM EMP WHERE NAME=:name }; JDBC: java.sql.PreparedStatement ps = con.prepareStatement( "SELECT ADDRESS FROM EMP WHERE NAME=?"); ps.setString(1, name); java.sql.ResultSet names = ps.executeQuery(); names.next(); addr = names.getString(1); names.close(); -- portable across platforms and DBMSs -- concise -- compile/bind time schema checking -- strong typing -- static SQL performance and authorization!!!
  12. 12. SQLJ example: INSERT one row SQLJ: #sql (con) {INSERT INTO T1 VALUES( :hv1, :hv2, :hv3) }; JDBC: CallableStatement mystmt = con.prepareCall( "INSERT INTO T1 VALUES(?,?,?)"); mystmt.setString(1,hv1); mystmt.setString(2,hv2); mystmt.setInt(3,hv3); mystmt.executeUpdate(); What if the table has 100 cols?
  13. 13. Compiling an SQLJ application SQLJ source Java Java source Java byte byte class ABC { codes Generic class ABC { codes Optional step: SQLJ call "stub" #sql Java Compiler DBMS-specific SELECT ... translator binder } Extracted SQL Extracted SQL } SELECT ... SELECT ... host var data host var data Extracted SQL JDBC "stub" JDBC "stub" SELECT ... host var data DBMS-specific "stub" JDBC default "stub" International DB2 Users Group
  14. 14. Java API Performance Comparisons 600 +35% 500 Transactions per second 400 +20% 300 200 100 0 JDBC V6 JDBC V7 SQLJ V6 SQLJ V7 Normalized throughput for zSeries G7 with 3 engines with 100% cache hit for JDBC. SQLJ advantage increased from 20% to 35% when Java overhead was reduced.
  15. 15. Java Stored Procedures SQLJ Part 1 specification Output parameters are single-element arrays Because Java doesn't allow modifying parms Result sets are not in catalog definition Result sets are in method signature as outputs Because "with return" is not universal Can be JDBC, SQLJ, or both Compiled Java on V5 and V6 JAR files support in V7 International DB2 Users Group
  16. 16. V7: Built-in Utility Stored Procedures As per SQLJ specification Invoked with CALL statement INSTALL_JAR (file URL) Installs the Java ARchive file into the DB2 catalog JAR file contains one or more Stored Procedures REPLACE_JAR REMOVE_JAR new JAR authorization GRANT USAGE ON JAR International DB2 Users Group
  17. 17. Tasks for OS/390 System Programmer Set up WLM environment, address space JCL Install IBM S/390 JDK w/enhancement Install JDBC/SQLJ driver Run db2genJDBC to generate DBRMs and bind into DB2 package -OR- use default .ser file with V7 driver Set up JAVAENV with "home" dirs Provide .profile for users International DB2 Users Group
  18. 18. JAVAENV DD CARD (in WLM address space JCL) Dataset containing RUNOPTS Applies to entire WLMENV, not individual SPs Must set JAVA_HOME IBM JDK 1.3.1 (persistent reusable technology) Must set DB2_HOME JDBC/SQLJ driver directory Can set CLASSPATH directory for user classes not in JAR all SP classes are shared Limited to 245 characters International DB2 Users Group
  19. 19. Stored Procedure Performance by Language Normalized Throughput - trans per second 1200 1000 800 Java- JDBC 600 Java - SQLJ C - static 400 200 0 Language International DB2 Users Group
  20. 20. What is DB2 Common Client? Reengineering of DB2 Connect and CAE ? ? Improved DB2 Connect and CAE consistency/performance much higher percentage of common code DRDA Improvements external capabilities internal performance improvements Scrollable cursors International DB2 Users Group
  21. 21. Objectives for new Java Client Single driver for Unix, Windows, and OS/390 eliminate major cause of Java porting problems Improved Java driver integration with DB2 Simplify install/deployment of Type 2 driver Improve JDBC and SQLJ performance SQLJ is now faster than JDBC on Unix/Windows International DB2 Users Group
  22. 22. DB2 Java Client Architecture Common Code for all drivers: JDBC APIs SQLJ APIs Type 2 driver Type 2 driver Type 4 Driver for for Unix/Windows OS/390 or z/OS DRDA over TCP/IP Local SQL API RRS Attach XA Support (Any DB2 server) International DB2 Users Group
  23. 23. New function in new Java Client Type 4 driver for thin clients Provide fully compliant JDBC 2.0 driver Trace improvements dynamically turn trace on/off multiple levels of trace detail Provide 100% Java application development process for SQLJ International DB2 Users Group
  24. 24. JCC: Type 4 Driver support Configuration D Java program OS/390 DB2 Network applet driver Character conversion is optional performance small download footprint International DB2 Users Group
  25. 25. DB2's type 4 JDBC driver Targeted at clients that fit this profile: prefer to not install the JDBC driver on their machine don't need high-end performance/scalability/availability The type 4 driver will NOT support: JTA (2--phase commit) parallel sysplex workload balancing connection concentrator functionality static SQL profiling Query Patroller some of the performance optimizations in the type 2 driver full range of code page translations If you are trying to support EJBs or high-end application servers, you should use the type 2 JDBC driver. International DB2 Users Group
  26. 26. New Java API Enhancements Scrollable cursor support Improved security for DB2 authentication Java API for Set Client Information (SQLESETI) Improved Java SQL error information Native DB2 server SQL error messages Connection pooling improvements International DB2 Users Group
  27. 27. Scrollable Cursor Support -- Exploits DB2 engine scrolling -- Supports update operations DB2 Server -- Java driver performs "local" scrolling within a block of data -- minimizes network traffic Java Application Query Current Result row Java Driver International DB2 Users Group
  28. 28. Java API for Set Client Information For DB2 for Unix and Windows users: provides additional monitoring information For DB2 for OS/390 and z/OS users: provides additional monitoring information all four strings are included in all IFC records Allows you to search accounting records or other IFC records for data related to a particular Java user or application. the last two strings can be used for WLM prioritization of the Java connections to DDF International DB2 Users Group
  29. 29. Improved SQL Error Information DB2Diagnosable class for reporting contents of the SQLCA and SQL error message text getSQLCode() getSQLErrmc() getSQLErrp() getSQLErrd() getSQLState() getSQLWarn() getSQLErrorMessage() Information is accessible for both JDBC and SQLJ whenever an SQL exception is thrown International DB2 Users Group
  30. 30. Native DB2 Server SQL Error Messages "Error Message" stored procedures are provided by each DB2 server (including DB2 for OS/390 V6 and V7) Allows DB2 client to return "native" error message text for the target DB2 server Native error message is only returned when explicitly requested getSQLErrorMessage() International DB2 Users Group
  31. 31. SQLJ Application Development Process (BIG improvements !) 100% Java application process eliminates DBRM files and .bnd files New SQLJ serialized profile format fully portable to all platforms -- user can deploy on any server platform without running db2profc on the target system. contains information needed for all BIND operations, without having to recustomize on each BIND migration path for old SQLJ serialized profiles to the new format Simplifies deployment of applications, but does require changes in existing procedures used by SQLJ users. International DB2 Users Group
  32. 32. Summary JDBC Driver Types Remember what Type 4 is designed for SQLJ - static SQL for a dynamic world Java stored procedures New combined client for all platforms Code portability International DB2 Users Group
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×