280 likes | 325 Vues
WAS connectivity to DB2 for z/OS JDBC and Structured Query Language for Java (SQLJ). After completing this unit, you should be able to: Understand the different JDBC types Describe the JDBC drivers provided with DB2 for z/OS Describe the “IBM DB2 Universal Driver for SQLJ and JDBC”:
E N D
WAS connectivity to DB2 for z/OS JDBC and Structured Query Language for Java (SQLJ)
After completing this unit, you should be able to: Understand the different JDBC types Describe the JDBC drivers provided with DB2 for z/OS Describe the “IBM DB2 Universal Driver for SQLJ and JDBC”: Architecture Connectivity type 2 and 4 XA support (two phase commit) JDBC and SQLJ Driver Manager interface and Data Source classes Describe the SQLJ customization process How to configure the connection from WAS to DB2 for z/OS Unit Objectives
IBM DB2 Universal Driver for SQLJ and JDBC • What is it? • Architected as an abstract JDBC processor • Independent of driver-type connectivity or target platform. • As an abstract machine, driver types become connectivity types • Architecture-neutral JDBC driver for: • Distributed DB2 access (Type 4 connectivity) and • Local DB2 access (Type 2 connectivity)
DB2 Universal Driver Objectives • Provided functions of DB2 UDB for Linux, UNIX, and Windows and those for z/OS are the same • Improves Family compatibility - true portability • Functionality enhancements for Type 2 and Type 4 drivers • Fully compliant with JDBC 3.0 standard • Provides a full Java application development process for SQLJ • Ease of installation and deployment for Type 4 driver • No dependencies on a runtime of DLL • Installation merely a copy of a .jar and .zip file • Reduces the client footprint for Linux, UNIX, and Windows platforms • Delivers functional and performance enhancements quicker • Improves trace capabilities
Supported Platforms and Connectivity • V1.0 supported Type 4 connectivity to most DB2s • Bundled with DB2 for LUW v8.1, WAS, and Cloudscape • V1.2 added Type 2 connectivity to DB2 for LUW, type 4 connectivity to iSeries • Bundled with DB2 for LUW v8.1 fix pack 2 • V1.3 added minimum JDBC 3 compliance • Bundled with DB2 for LUW v8.1 fix pack 3 • V1.4 added Beta Type 2 connectivity to z/OS v8 • V1.5 added full JDBC 3 compliance • Bundled with DB2 for LUW v8.1 fix pack 4 • V1.6 added Beta Type 4 XA (2 phase commit) connectivity to DB2 for z/OS V7 and V8 • V1.7 added Type 4 XA connectivity to DB2 V7 z/OS • V2.1 GA of z/OS Type 2 JNI-based local connectivity • Released via APAR PQ80841 / PTF UQ85607 for DB2 for z/OS and OS/390 V7 • Production release via APAR PQ85053 / PTF UQ85928 for DB2 for z/OS V8 • V2.3 Added official support of T4 XA connectivity from DB2 for z/OS to DB2 for LUW • Available with APAR PQ93458
Migration to the Universal Driver • New Java Universal Driver will eventually replace existing legacy implementations of DB2 JDBC drivers • Subtle behavioral differences from legacy drivers are to be expected • Existing drivers do not have the same behavior • Impossible to match JDBC behavior of LUW and z/OS simultaneously in all cases • Migration should be done gradually as there will be differences • db2sqljupgrade utility for DB2 for z/OS serialized profiles
Connecting to a DB2 • Via a DriverManager interface • A driver must be registered (specific) • No connection pooling • Application code is NOT portable • (For batch...) • Via a Data source • JDBC 2.x Standard Extension • (Used with WAS 3.5, v4, v5)
Java API Enhancements • Scrollable cursor support • Batched updates support • Improved Java SQL error information • Native DB2 server SQL error messages • Java API for set client information (SQLESETI) • Built-in DB2SystemMonitor class (application-driver-network-server) • Multiple open result sets • SAVEPOINT support • Auto-generated keys • Enhanced LOB support
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 • Errors detected earlier • Productivity/manageability • Less code written by the application programmer • Resulting code is easier to maintain • Static SQL packages for accounting/monitoring • Static SQL locks in access path, so that access path changes don't occur without a conscious choice
Comparing SQLJ and JDBC Coding • Retrieving a single row from DB2 • SQLJ String addr; String name; .... #sql [ctx] {SELECT address INTO :addr FROM emp WHERE name =:name}; • JDBC String addr; String name; .... PreparedStatement pstmt = con.prepareStatement( “SELECT address FROM emp WHERE name = ?”); pstmt.setString(1, name); ResultSet names = pstmt.executeQuery(); names.next(); addr = names.getString(1); names.close(); pstmt.close();
WAS Connectivity to DB2 for z/OS • DB2 Universal Driver for SQLJ and JDBC installation • WAS V5 configuration to use the DB2 Universal Driver
DB2 Universal Driver for SQLJ and JDBC Installation • Required Environment Variables: • PATH • $JDBC_HOME/bin • CLASSPATH • $JDBC_HOME/classes/db2jcc.jar • $JDBC_HOME/classes/db2jcc_javax.jar • $JDBC_HOME/classes/sqlj.zip • $JDBC_HOME/classes/db2jcc_licence_cisuz.jar • LIBPATH (for type 2) • $JDBC_HOME/lib • STEPLIB (for type 2) • SDSNEXIT,SDSNLOAD,SDSNLOD2 • Create the DB2 Universal Driver stored procedures and metadata • Check DESCSTAT=YES in zParms • Run DSNTIJMS job from SDSNSAMP • Bind the DB2 Universal Driver packages with the DB2Binder utility • java com.ibm.db2.jcc.DB2Binder -url jdbc:db2: //server:port/database -user userid -password password • Run the DB2T4XAIndoubtUtil utility for DB2 V7 • java com.ibm.db2.jcc.DB2T4XAIndoubtUtil -url jdbc:db2: //server:port/database -user userid -password password
WAS V5 Configuration to Use the DB2 Universal Driver • Configure the DB2 Universal JDBC Driver. • Define a DB2 Universal JDBC Driver Provider for WebSphere Application Server for z/OS. • Define a DB2 Universal JDBC Driver Provider DataSource.
Having completed this unit, you should be able to: Understand the different JDBC types Describe the JDBC drivers provided with DB2 for z/OS Describe the “IBM DB2 Universal Driver for SQLJ and JDBC”: Architecture Connectivity type 2 and 4 XA support (two phase commit) JDBC and SQLJ Driver Manager interface and Data Source classes Describe the SQLJ customization process How to configure the connection from WAS to DB2 for z/OS Unit Summary