1 / 49

E32

E32. JDBC Access to IMS DB from DB2, CICS, and Websphere. Christopher Holtz, Kyle Charlet. Las Vegas, NV September 15 – September 18, 2003. Overview. IMS Java What Is IMS Java Why Use IMS Java IMS Java Class Library Architecture JDBC and J2EE Dealership Sample Application

gili
Download Presentation

E32

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. E32 JDBC Access to IMS DB from DB2, CICS, and Websphere Christopher Holtz, Kyle Charlet Las Vegas, NV September 15 – September 18, 2003

  2. Overview • IMS Java • What Is IMS Java • Why Use IMS Java • IMS Java Class Library Architecture • JDBC and J2EE • Dealership Sample Application • Front-end/Back-end split • Environments • Non-Managed • IMS • CICS • DB2 • Managed • WebSphere

  3. What is IMS Java? • A new feature in IMS v7 • A set of classes that... • Offers Java support to access IMS Databases from various environments (IMS, CICS, DB2, WebSphere) • Enables SQL access through the JDBC interface • Java Virtual Machine (JVM) support in dependent regions • JDK 1.3 support • JDBC 2.1 support • Just-In-Time (JIT) compilation • Resetable JVM

  4. Why IMS Java? • Rapid Application Development • Reduce the Total Cost of Ownership (TCO) for IT and Data Management needs and Total Time to Value (TTV) • Extend the life and scope of IMS applications • Minimum amount of impact on core applications and effort for developers, system programmers, and DBAs • Leverage existing marketplace, industry-sanctioned standards - they are the slowest changing and most persistent • JDBC and J2EE are standards – help to minimize specific back end knowledge of IMS • Leverage new and abundant skills in the marketplace and mitigate the loss of 390 skills for customers • Integrate with other products • Our response is IMS Java, Web Services, WebSphere support, CICS support, DB2 SP support

  5. Java Class Library IMS DB Metadata Business Logic IMS Dep. Region Transaction and Message Processing IMS Java App DLI Database View Customer Code A p p DB JDBC / SQL IMS Java Class Library Base Mapping to DL/I APIs JNI CEETDLI Interface C Layer Interface to IMS JDBC, JCA interface Java to C interface

  6. IMS Java App IMS Java App IMS Java App IMS Java App IMS Java App IMS Java App DLI Database View DLI Database View DLI Database View DLI Database View DLI Database View DLI Database View A p p A p p A p p A p p A p p A p p DB DB DB DB DB DB JDBC / SQL JDBC / SQL JDBC / SQL JDBC / SQL JDBC / SQL JDBC / SQL Base Base Base Base Base Base JNI JNI JNI JNI JNI JNI CEETDLI Interface CEETDLI Interface CEETDLI Interface CEETDLI Interface CEETDLI Interface CEETDLI Interface IMS Java – The Big Picture DB2 WebSphere CICS Stored Procedure EJB JCICS Java Virtual Machine Java Virtual Machine Java Virtual Machine IMS / TM I F P M P P B M P ODBA DRA IMS DB JMP JBP Java Virtual Machine DBDGEN PSBGEN ACBGEN DL/I Model DBDs PSBs COPYLIB

  7. Overview • IMS Java • What Is IMS Java • Why Use IMS Java • IMS Java Class Library Architecture • JDBC and J2EE • Dealership Sample Application • Front-end/Back-end split • Environments • Non-Managed • IMS • CICS • DB2 • Managed • WebSphere

  8. JDBC and J2EE Standards Evolution • Standard way to Query Database (relational) • Structured Query Language (SQL) • Communicating Query to Database • Open Database Connectivity (ODBC) – C based • Standard API to Query Database • “Java Database Connectivity” (JDBC) – Platform/DB Independent • Standard API to Establish Connection • J2EE Connection Architecture (JCA, J2C) • Standard API to Build Enterprise Applications • Java 2 Enterprise Edition (J2EE)

  9. J2EE Architecture Applet Container Web Container EJB Container HTTP SSL Applet Servlet EJB JSP JMS JNDI JTA Java Mail RMI/IIOP JDBC JMS JNDI JTA Java Mail RMI/IIOP JDBC Database J2SE HTTP SSL JAF JAF J2SE J2SE Application Client Container Application Client JMS JNDI RMI/IIOP JDBC J2SE

  10. J2EE Connection Architecture • Proposed Java standard architecture for deploying a resource adapter in a J2EE compliant application server • Defines contracts between... • resource adapter and the application component • resource adapter and the application server

  11. J2EE Connection Architecture Container- Component Contract Application Component Application Server JDBC Resource Adapter System Contracts WebSphere IMS Java EIS specific interface Enterprise Information System IMS

  12. DataSource • Factory for connections to a physical data source • Replacement to the DriverManager facility • Required when running in a managed environment (WebSphere) • Typically registered with a naming service based on the Java™ Naming and Directory (JNDI) API. • Names are associated with objects and objects are found based on their names. • DataSource objects have properties that can be modified when necessary • Code accessing the data source does not need to be changed • (Properties include: DRA Name, DLIDatabaseView)

  13. DataSource DataSource DRA: DBView: DRA: DBView: SYS3 SYS1 TestApp2DatabaseView TestAppDatabaseView DataSource DRA: DBView: DataSource Deployment AbcdefDB EmployeeDB JNDI Admin Tool SYS1 AUTPSB11DatabaseView

  14. EmployeeDB DataSource DataSource DataSource DRA: DBView: DRA: DBView: DRA: DBView: SYS1 SYS1 SYS3 TestAppDatabaseView TestApp2DatabaseView AUTPSB11DatabaseView "DealershipDB" DataSource DRA: DBView: SYS1 AUTPSB11DatabaseView DataSource Deployment AbcdefDB JNDI DealershipDB Admin Tool

  15. EmployeeDB DataSource DataSource DataSource DataSource DataSource DRA: DBView: DRA: DBView: DRA: DBView: DRA: DBView: DRA: DBView: SYS1 SYS3 SYS1 SYS1 SYS1 "DealershipDB" TestApp2DatabaseView AUTPSB11DatabaseView TestAppDatabaseView AUTPSB11DatabaseView AUTPSB11DatabaseView "DealershipDB" DataSource DataSource DRA: DBView: DRA: DBView: SYS1 SYS1 AUTPSB11DatabaseView AUTPSB11DatabaseView DataSource Retrieval AbcdefDB DealershipDB JNDI EJB 1 EJB 2

  16. Overview • IMS Java • What Is IMS Java • Why Use IMS Java • IMS Java Class Library Architecture • JDBC and J2EE • Dealership Sample Application • Front-end/Back-end split • Environments • Non-Managed • IMS • CICS • DB2 • Managed • WebSphere

  17. DEALER MODEL SALESPER ORDER SALES STOCK SALESINF Dealership Sample Database

  18. Dealership Sample Application • Performs specific queries to the database • List all models • List details of a particular model • Split into a front-end and a back-end • Front-End (Environment Specific) • Process message queue (IMS) • Invoke stored procedure (DB2) • JCICS application (CICS) • Enterprise Java Bean (WebSphere) • Back-End (Environment Independent) • Performs all query processing • Sends data back to the caller (front-end)

  19. Dealership Sample (Back-End) public class AutoDealership { /** The database connection is created by each front-end and given to the single back-end **/ publicAutoDealership(Connection connection) { this.connection = connection; } public Vector listModels() throws SQLException { SQL processing logic here... } public Vector findCar(FindCarInput input) throws SQLException { SQL processing logic here... } }

  20. Dealership Sample (Back-End) public Vector listModels() throws SQLException { // Create the SQL statement - no inputs needed String query = "SELECT * FROM Order.ModelSegment"; // Execute the query Statement statement = connection.createStatement(); ResultSet results = statement.executeQuery(query); process results... }

  21. Dealership Sample (Back-End) public Vector listModels() throws SQLException { create statement and execute query... Vector models = newVector(); ListModelOutput output = null; while (results.next()) { output = new ListModelOutput(); output.setModelType(results.getString("ModelType")); output.setMake(results.getString("Make")); output.setModel(results.getString("Model")); output.setYear(results.getString("Year")); models.addElement(output); } return models; }

  22. Overview • IMS Java • What Is IMS Java • Why Use IMS Java • IMS Java Class Library Architecture • JDBC and J2EE • Dealership Sample Application • Front-end/Back-end split • Environments • Non-Managed • IMS • CICS • DB2 • Managed • WebSphere

  23. Managed Environments WebSphere 4.01 (JVM) Non-Managed Environments IMS TM 7.1 ( Resetable JVM) IMS TM 8.1 (Resetable JVM) CICS 2.1 (Resetable JVM) DB2 V7 (Resetable JVM) IMS Java App IMS Java App IMS Java App IMS Java App IMS Java App DLI Database View DLI Database View DLI Database View DLI Database View DLI Database View A p p A p p A p p A p p A p p DB DB DB DB DB JDBC / SQL JDBC / SQL JDBC / SQL JDBC / SQL JDBC / SQL Base Base Base Base Base JNI JNI JNI JNI JNI CEETDLI Interface CEETDLI Interface CEETDLI Interface CEETDLI Interface CEETDLI Interface Running Environments DB2 WebSphere CICS Stored Procedure EJB JCICS Java Virtual Machine Java Virtual Machine Java Virtual Machine IMS / TM I F P M P P B M P ODBA DRA IMS DB JMP JBP Java Virtual Machine

  24. Non-Managed Connection Establishment • Non-Managed Environment (IMS, DB2, CICS) • An application can construct a DataSource prior to its use • Alternatively, a DataSource can be bound to the namespace • Application acquires a Connection from the DataSource IMSJdbcManagedConnectionFactory mcf = newIMSJdbcManagedConnectionFactory(); mcf.setDRAName("SYS1"); mcf.setDatabaseViewName("samples.dealership.AUTPSB11DatabaseView"); DataSource dataSource = (DataSource)mcf.createConnectionFactory(); Connection connection = dataSource.getConnection();

  25. IMS TM Java Access to IMS Data • Run in JVM • IMS 7.1 or later • JDK 1.3 • JDBC 2.1 • Can only connect to one PSB • Synchpoints done by calls to application package

  26. IMS TM Java Access to IMS Data // Import the IMS Java packages import com.ibm.ims.db.*; import com.ibm.ims.application.*; publicclass IMSAuto { /* Entry point of the application. */ public static void main(String args[]) { // setup message queue access. IMSMessageQueue messageQueue = new IMSMessageQueue(); InputMessage inputMessage = new InputMessage(); while (messageQueue.getUniqueMessage(inputMessage)) { create connection… call back-end… reply to message queue… commit… } } }

  27. IMS TM Java Access to IMS Data /* Entry point of the application. */ public static voidmain(String args[]) { access message queue and get message... // Get connection IMSJdbcManagedConnectionFactory mcf = new IMSJdbcManagedConnectionFactory(); mcf.setDatabaseViewName("samples.dealership.AUTPSB11DatabaseView"); DataSource dataSource = (DataSource)mcf.createConnectionFactory(); Connection connection = dataSource.getConnection(); // Pass connection to back-end AutoDealership autoDealership = newAutoDealership(connection); // Call listModels method and get results in 'output' Object Vector output = autoDealership.listModels(); reply to message queue... commit... }

  28. IMS TM Java Access to IMS Data /* Entry point of the application. */ public static voidmain(String args[]) { access message queue and get message... create connection... call back-end... // Format and insert output message OutputMessage outputMessage = new OutputMessage(output); messageQueue.insertMessage(outputMessage); // Close connection and commit database before we get next Message. connection.close(); IMSTransaction.getTransaction().commit(); } }

  29. CICS Java Access to IMS Data • Run in JVM • CICS TS 2.1 • JCICS API • Java version of the CICS API • JDK 1.3 • JDBC 2.1 • Can only connect to (allocate) one PSB at a time • Only one Connection active at a time in an application • Synchpoint done at deallocate PSB

  30. CICS Java Access to IMS Data // Import the JCICS package import com.ibm.cics.server.*; publicclass CICSAuto { private static Task task = Task.getTask(); /* Invoked when the CICS transaction corresponding to this class is executed. */ public static void main(CommAreaHolder cah) { CICSAuto application = newCICSAuto(); application.listModels(); } /* The listModels method provides a collection of all automobile models in the database */ public void listModels() { method logic here... } }

  31. CICS Java Access to IMS Data /* The listModels method provides a collection of all automobile models in the database */ public voidlistModels() { // Get connection IMSJdbcManagedConnectionFactory mcf = new IMSJdbcManagedConnectionFactory(); mcf.setDatabaseViewName("samples.dealership.AUTPSB11DatabaseView"); DataSource dataSource = (DataSource)mcf.createConnectionFactory(); Connection connection = dataSource.getConnection(); // Pass connection to back-end AutoDealership autoDealership = newAutoDealership(connection); // Call listModels method and get results in 'output' Object Vector output = autoDealership.listModels(); display results... }

  32. DB2 Stored Procedure Support • Run in JVM • DB2 Version 7 • APAR PQ46673 (resetable JVM) • Stored Procedures that access IMS Databases • User-written structured query language (SQL) programs that are stored at the DB2 server and can be invoked by a client application • DB2 handles synchpoint (not stored procedure) • DRA table and name required

  33. DB2 Stored Procedure Support public classDB2Auto() { public static voidlistModels(String[] make, String[] model) { // Get connection IMSJdbcManagedConnectionFactory mcf = new IMSJdbcManagedConnectionFactory(); mcf.setDRAName("SYS1"); mcf.setDatabaseViewName("samples.dealership.AUTPSB11DatabaseView"); DataSource dataSource = (DataSource)mcf.createConnectionFactory(); Connection connection = dataSource.getConnection(); // Pass connection to back-end AutoDealership autoDealership = newAutoDealership(connection); Vector output = autoDealership.listModels(); // Return data to client make[0] = ((ListModelOutput)output.elementAt(0)).getMake(); model[0] = ((ListModelOutput)output.elementAt(0)).getModel(); } }

  34. Managed Connection Establishment • Managed Environment (WebSphere) • DataSource deployed in JNDI namespace using: • WebSphere Application Server for z/OS and OS/390 Administration tool (4.01) • Web UI tool (5.0) • Application (EJB) makes a request for the DataSource and acquires a Connection from it Context ctx = newInitialContext(); DataSource dataSource = (DataSource)ctx.lookup("DealershipDB"); Connection con = dataSource.getConnection();

  35. WebSphere 4.01, 5.0 Support • Runs in JVM • JDK 1.3 • JDBC 2.1 • Applications run as Enterprise Java Beans (EJBs) • Access IMS databases through ODBA/DRA • J2EE Connection Architecture • Managed Environment • Connections are managed by application server

  36. Enterprise Archive (EJB) public Vector listModels() throws javax.ejb.EJBException{ InitialContextinitialContext = new InitialContext(); // perform JNDI lookup to obtain the DataSource and get the Connection DataSource dataSource = (DataSource)initialContext.lookup("DealershipDB"); Connection connection = dataSource.getConnection(); AutoDealership dealer = new AutoDealership(connection); Vector output = dealer.listModels(); return output; }

  37. Overview of Application Development Steps • Obtain Resource Adapter Archive (.rar) • Deploy Resource Adapter Archive (install into server) • Deploy DataSource (represents connection to a database) • Deploy Resource Adapter Instance • Build and Deploy Enterprise Archive (.ear) • Two main development components • Servlet • Accesses EJB and invokes methods on the EJB • EJB • Accesses deployed DataSource (resource adapter instance) • Uses DataSource to connect to database and performs business logic

  38. Deploy IMS Java Resource Adapter ra.xml A p p DB JDBC / SQL • We provide a J2EE Resource Adapter Archive (RAR) file containing: • Deployment descriptor (ra.xml) • IMS Custom Service (IMSJdbcCustomService.xml) • Handles initialization and termination of IMS • Latest information associated with installing the IMS JDBC resource adapter (howto.html) • WebSphere will provide tooling to deploy RAR file into server • Add IMS Custom Service • Set CLASSPATH and LIBPATH • Understand how to deploy an instance of an IMS Java Resource Adapter (via ra.xml) Base JNI CEETDLI Interface

  39. DataSource Deployment • Use WebSphere Application Server for z/OS and OS/390 Administration tool • Shipped with WebSphere on OS/390 • Create J2EE Resource Instance • Specify IMSJdbcDataSource as the J2EE Resource Type • Configure • DRA Startup Table • Generated DLIDatabaseView • Deploy JNDI Deploy "DealershipDB" Admin Tool DataSource SYS1 DRA: DBView: AUTPSB11DatabaseView

  40. Enterprise Archive (.ear) application.xml Web Archive (.war) Java Archive (.jar) web.xml ejb-jar.xml Home HTML Servlet Remote JSP EJB Build and Deploy Enterprise Archive (ear) • J2EE Enterprise Application Archive • Complete J2EE application • Must contain • One or more J2EE modules (Java Archive) • Deployment descriptor (application.xml) • Represents a top level view of a J2EE application's contents • May contain • One or more Web modules (Web Archive) • Libraries referenced by J2EE modules

  41. Enterprise Archive (Servlet) Web Archive (.war) web.xml • Looks up the EJB home interface in JNDI • Using the home interface, creates the EJB remote interface • Invokes methods on the remote interface • Remote interface uses IIOP to communiate to EJB • Pass-through interface • Passes results of method to a Java Server Page (JSP) for displaying on a web browser HTML Servlet JSP

  42. Enterprise Archive (EJB) Java Archive (.jar) • Receives requests from the servlet • Obtains a connection • Looks up the deployed DataSource instance and requests a connection from it • Accesses the database(s) and performs business logic • Sends the results back to the servlet to display ejb-jar.xml Home Remote EJB

  43. Enterprise Archive (.ear) A p p DB JDBC / SQL Base Java Archive (.jar) Web Archive (.war) JNI CEETDLI Interface web.xml ejb-jar.xml HTML Servlet Home Remote JSP EJB WebSphere Runtime JNDI Home Websphere z/OS application.xml

  44. Servlet EJB HTML JSP A p p DB JDBC / SQL Base Java Archive (.jar) Web Archive (.war) JNI CEETDLI Interface WebSphere Runtime JNDI Home Websphere z/OS application.xml web.xml ejb-jar.xml Home Remote HTML Servlet EJB JSP

  45. DataSource DataSource DRA: DBView: DRA: DBView: SYS1 SYS1 AUTPSB11DatabaseView AUTPSB11DatabaseView A p p DB JDBC / SQL HTTP Base JNI CEETDLI Interface WebSphere Runtime JNDI Home Websphere z/OS Servlet Home EJB HTML Remote Connection JSP

  46. Remote Database Services • Available IMS Version 9 • Ability to access IMS DL/I data from a distributed J2EE server • Complete client application deployed on distributed server • Distributed functionality is transparent to client application • Websphere Application Server 5.0 for z/OS still required (server-side) • All client-server communication is handled by new IMS Java components • IMS JDBC distributed Resource Adapter (client-side RAR) • Container Managed EJB (server-side EAR) • Bean Managed EJB (server-side EAR)

  47. JCA RA JDBC Enterprise Archive (.ear) application.xml Web Archive (.war) A p p DB JDBC / SQL web.xml ejb-jar.xml Base Java Archive (.jar) JNI CEETDLI Interface WebSphere Runtime JNDI Home Websphere z/OS Websphere z/OS, distributed BM EJB EJB Servlet CM EJB JSP HTML Home Remote HTML Servlet EJB JSP

  48. DataSource DataSource JCA RA JDBC A p p DB JDBC / SQL HTTP Base JNI CEETDLI Interface WebSphere Runtime JNDI Home Home Websphere z/OS Websphere z/OS, distributed Remote BM EJB EJB Connection IIOP Servlet Connection CM EJB JSP HTML ORB

  49. Conclusion Managed Non-Managed J2EE Application IMS JMP/JBP JCICS DB2 Stored Proc Client Servlet EJB Application Application HTML Stored Procedure Common Common Common JSP Common Application (Query Processing) DLI Database View A p p DB JDBC / SQL Common ODBA Base DRA JNI IMS DB CEETDLI Interface

More Related