Application Development A Cocktail of Java and MCP. MCP Guru Series Dan Meyer & Pramod Nair



Similar documents
Database Access from a Programming Language: Database Access from a Programming Language

Database Access from a Programming Language:

The JAVA Way: JDBC and SQLJ

COSC344 Database Theory and Applications. Java and SQL. Lecture 12

Cross Platform Software Release Capabilities

JDBC. It is connected by the Native Module of dependent form of h/w like.dll or.so. ex) OCI driver for local connection to Oracle

What is ODBC? Database Connectivity ODBC, JDBC and SQLJ. ODBC Architecture. More on ODBC. JDBC vs ODBC. What is JDBC?

Chapter 9 Java and SQL. Wang Yang wyang@njnet.edu.cn

Java and Databases. COMP514 Distributed Information Systems. Java Database Connectivity. Standards and utilities. Java and Databases

Database Programming. Week *Some of the slides in this lecture are created by Prof. Ian Horrocks from University of Oxford

Brazil + JDBC Juin 2001, douin@cnam.fr

Applets, RMI, JDBC Exam Review

Why Is This Important? Database Application Development. SQL in Application Code. Overview. SQL in Application Code (Contd.

Java DB Performance. Olav Sandstå Sun Microsystems, Trondheim, Norway Submission ID: 860

OS3036 Put Your ClearPath In Your Pocket

SQL and programming languages

Remote Method Invocation in JAVA

JDBC (Java / SQL Programming) CS 377: Database Systems

CS 377 Database Systems SQL Programming. Li Xiong Department of Mathematics and Computer Science Emory University

FileMaker 8. Installing FileMaker 8 ODBC and JDBC Client Drivers

Distributed Network Management Using SNMP, Java, WWW and CORBA

Java MySQL Connector & Connection Pool

ClearPath MCP Developer Studio

LSINF1124 Projet de programmation

Course Objectives. Database Applications. External applications. Course Objectives Interfacing. Mixing two worlds. Two approaches

Using Netbeans and the Derby Database for Projects Contents

Security Code Review- Identifying Web Vulnerabilities

Java and Microsoft Access SQL Tutorial

CS/CE 2336 Computer Science II

Supplement IV.C: Tutorial for Oracle. For Introduction to Java Programming By Y. Daniel Liang

CS2506 Operating Systems II Lab 8, 8 th Tue/03 /2011 Java API

Microsoft SQL Server Features that can be used with the IBM i

Custom Encryption in Siebel & Siebel Web Service Security Test Guide 1.0

Java Server Pages and Java Beans

CS346: Database Programming.

Put a Firewall in Your JVM Securing Java Applications!

SQL and Java. Database Systems Lecture 19 Natasha Alechina

Security Module: SQL Injection

Java Programming. JDBC Spring Framework Web Services

CSc 230 Software System Engineering FINAL REPORT. Project Management System. Prof.: Doan Nguyen. Submitted By: Parita Shah Ajinkya Ladkhedkar

Transparent Redirection of Network Sockets 1

How To Use The Database In Jdbc.Com On A Microsoft Gdbdns.Com (Amd64) On A Pcode (Amd32) On An Ubuntu (Amd66) On Microsoft

FileMaker 11. ODBC and JDBC Guide

Self-test Database application programming with JDBC

Network/Socket Programming in Java. Rajkumar Buyya

Division of Informatics, University of Edinburgh

How To Use A Sas Server On A Java Computer Or A Java.Net Computer (Sas) On A Microsoft Microsoft Server (Sasa) On An Ipo (Sauge) Or A Microsas (Sask

TECH TUTORIAL: EMBEDDING ANALYTICS INTO A DATABASE USING SOURCEPRO AND JMSL

FTP Client Engine Library for Visual dbase. Programmer's Manual

Comparing the Effectiveness of Penetration Testing and Static Code Analysis

Performance Tuning for the JDBC TM API

Introduction Web Portal Main Page Group Management Create group Modify Group Member List... 5

Oracle WebLogic Foundation of Oracle Fusion Middleware. Lawrence Manickam Toyork Systems Inc

Java SE 7 Programming

Abstract. Introduction. Web Technology and Thin Clients. What s New in Java Version 1.1

Java SE 7 Programming

Elements of Advanced Java Programming

Services. Relational. Databases & JDBC. Today. Relational. Databases SQL JDBC. Next Time. Services. Relational. Databases & JDBC. Today.

Supplement IV.D: Tutorial for MS Access. For Introduction to Java Programming By Y. Daniel Liang

NGASI AppServer Manager SaaS/ASP Hosting Automation for Cloud Computing Administrator and User Guide

Working With Derby. Version 10.2 Derby Document build: December 11, 2006, 7:06:09 AM (PST)

Version Overview. Business value

Jaybird 2.1 JDBC driver. Java Programmer's Manual

CHAPTER 3. Relational Database Management System: Oracle. 3.1 COMPANY Database

FileMaker 14. ODBC and JDBC Guide

An Introduction to Application Security in J2EE Environments

Transparent Redirection of Network Sockets 1

Module 17. Client-Server Software Development. Version 2 CSE IIT, Kharagpur

WEB DATABASE PUBLISHING

Figure 1. Accessing via External Tables with in-database MapReduce

Java SE 7 Programming

Running and Testing Java EE Applications in Embedded Mode with JupEEter Framework

Introduction to HP ArcSight ESM Web Services APIs

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

DELIVER Utility for MCP Systems

Enterprise Java. Where, How, When (and When Not) to Apply Java in Client/Server Business Environments. Jeffrey Savit Sean Wilcox Bhuvana Jayaraman

1 SQL Data Types and Schemas

To Java SE 8, and Beyond (Plan B)

Evaluation. Copy. Evaluation Copy. Chapter 7: Using JDBC with Spring. 1) A Simpler Approach ) The JdbcTemplate. Class...

Fachbereich Informatik und Elektrotechnik SunSPOT. Ubiquitous Computing. Ubiquitous Computing, Helmut Dispert

unisys ClearPath Enterprise Servers SQL Query Processor for ClearPath MCP Installation and Operations Guide ClearPath MCP 16.0

CS506 Web Design and Development Solved Online Quiz No. 01

Java SE 8 Programming

LAE 5.1. Windows Server Installation Guide. Version 1.0

Replication on Virtual Machines

EJB 3.0 and IIOP.NET. Table of contents. Stefan Jäger / stefanjaeger@bluewin.ch

Crash Course in Java

BlackBerry Enterprise Service 10. Secure Work Space for ios and Android Version: Security Note

Web Application Security. Vulnerabilities, Weakness and Countermeasures. Massimo Cotelli CISSP. Secure

3.5. cmsg Developer s Guide. Data Acquisition Group JEFFERSON LAB. Version

Operating Systems and Networks

S y s t e m A r c h i t e c t u r e

Middleware Lou Somers

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

Software Architecture Document

CA Workload Automation Agent for Databases

Transcription:

Application Development A Cocktail of Java and MCP MCP Guru Series Dan Meyer & Pramod Nair

Agenda Which of the following topics can be found in an Application Development cocktail? o Calling Java from COBOL-85 o Using Java7 NIO2 features o Accessing DMSII from Java o All of the above o Some of the above o None of the above 2013 Unisys Corporation. All rights reserved. 2

A Cocktail of Java and MCP Calling Java from COBOL85

Application Development Wouldn t It Be Nice by the Beach Boys Wouldn't it be nice if we were older Then we wouldn't have to wait so long Wouldn't it be nice to live together In the kind of world where we belong You know its gonna make it that much better When we can say goodnight and stay together Wouldn t it be nice if: Your favorite programming language could be used for everything? You could find libraries that could be easily called and not support? There were an endless supply of COBOL programmers? What a Wonderful World that would be 2013 Unisys Corporation. All rights reserved. 4

Mixing Languages Through Libraries We Invented It Application Program Interface (Wii API) A was well documented, in-house developed standard Specific application during definition Communication over TCPIP (Socket-to-Socket) Common Object Request Broker Architecture (CORBA) A well-defined Object Management Group (OMG) standard Vendor-independent architecture and structure Communication over the Internet Inter-Orb Protocol (IIOP) Java Native Interface (JNI) A well-defined Java standard Defined for C Java DLL 2013 Unisys Corporation. All rights reserved. 5

COBOL???? COBOL app needs to access an Oracle database COBOL app needs to be web services enabled COBOL app needs to create a PDF file COBOL app needs to decrypt messages encrypted with COBOL app needs to 2013 Unisys Corporation. All rights reserved. 6

Java Invocation Interface (Jii) COBOL-85 (via ALGOL) calling Java methods Can invoke standard Java packages Usually need minimal Java code Native program is in control Uses Java as a private library JVM ends when the native program ends 2013 Unisys Corporation. All rights reserved. 7

Java Invocation Interface (Jii) API developed to call Java methods Simplified with com.unisys.mcp.tools.jifgen Reads Java source or class and generates entrypoint INCLUDE file Does all the dirty work of calling JNI methods Based on C JNI method definition in a generated ALGOL library Calls for identifying methods by name Calls for identifying objects by name Chatty and error prone Application JNI Interfaces JNI Proxy Lib Java Worker Java Worker Java Class JVM JProcessor 2013 Unisys Corporation. All rights reserved. 8

Jii Development Process Demo Create or identify a Java class with public methods Demo COBOL program needing to accessing remote database using data from a DMSII database Java application needs 3 methods Connect to the remote database getconnection() Close database connection releaseconnection() Retrieve record using key passed from COBOL-85 and compare data compareequal (int id, String word) UniverseDemo.zip Application JNI Interfaces JNI Proxy Lib Java Worker Java Worker Java Class JVM JProcessor 2013 Unisys Corporation. All rights reserved. 9

Jii Development Process Demo package com.unisys.mcp.universe; import java.sql.*; public class Demo { static Connection con = null; static PreparedStatement pstmt = null; static String url = jdbc:unisys:dmsql:unisys.dmsii ; public static boolean releaseconnection() { try { if (pstmt <> null) pstmt.close(); if (con <> null) con.close(); return true; } catch (SQLException seq) { sqe.printstacktrace(); return false; } } 2013 Unisys Corporation. All rights reserved. 10

Jii Development Process Demo public static boolean getconnection() { boolean onmcp = System.getProperty("os.name").contains("MCP"); String hostname = onmcp? EVLANMCP : ECCSK ; try { Class.forName ("com.unisys.jdbc.dmsql.driver ) url = url + resource=universedb; + host= + hostname + ;port=1897 + user=java;password=java ); con = DriverManager.getConnection (url); if (con == null) return false; pstmt = con.preparestatement ("SELECT * FROM universedb.words + where word_id =?"); if (pstmt == null) return false; return true; } catch (SQLException sqe) { sqe.printstacktrace(); return false; } } 2013 Unisys Corporation. All rights reserved. 11

Jii Development Process Demo public static boolean compareequal (int id, String worda) { worda = worda.trim(); try { pstmt.setint(1, id); ResultSet rs = pstmt.executequery(); if (rs.next() { String a = rs.getstring( dmsii_word_a ); if (a.compareto(worda)!= 0) { System.err.println (id + ) + a + <> + worda); return false; } } else { System.err.println (id + ) not found [ + worda + ] ); return false; } return true; } catch (SQLException sqe) { sqe.printstacktrace(); return false; } } 2013 Unisys Corporation. All rights reserved. 12

Jii Development Process Demo } public static void main (String args[]) { String command = select * from dmsii_words ); try { if (getconnection()) { Statement stmt = con.createstatement(); ResultSet rs = stmt.executequery(command); while (rs.next()) { int id = rs.getint ( word_id ); String worda = rs.getstring ( dmsii_word_a ); System.out.println ( ( + id + ) + worda.trim() + : + compareequal (id, worda.getbytes()) ); } rs.close(); stmt.close(); releaseconnection(); } } catch (Exception e) { ; } } 2013 Unisys Corporation. All rights reserved. 13

Jii Development Process Demo Run JifGen to create files to be used on MCP RUN *DIR/JRE7/BIN/MCPTOOLS ("JifGen -verbose -cobol -d /-/JAVA/USERCODE/JAVA/UD -classpath /-/JAVA/DIR/JAVA/universedemo.jar -output DEMO com.unisys.mcp.universe.demo") [Creating file /-/JAVA/USERCODE/JAVA/UD/DEMOINCL.C85_M] [Creating file /-/JAVA/USERCODE/JAVA/UD/DEMO.ALG_M] Application JNI Interfaces JNI Proxy Lib Java Worker Java Worker Java Class JVM JProcessor 2013 Unisys Corporation. All rights reserved. 14

Jii Development Process Demo Modify existing application to use Java methods Include sections from *DIR/JRE7/JDK/INCLUDE/JNILIB/COBOL Include sections from "DEMOINCL.C85_M CALL JNI-CREATE-JAVA-VM USING GIVING RESULT. Do work using the following generated entry points ENTRY PROCEDURE INITIALIZE-DEMO ENTRY PROCEDURE DEMO-DEMO-GET-CONNECTION ENTRY PROCEDURE DEMO-DEMO-RELEASE-CONNECTION ENTRY PROCEDURE DEMO-DEMO-COMPARE-EQUAL CALL JNI-DESTROY-JAVA-VM USING GIVING RESULT. Create ALGOL library DEMO/LIBRARY COMPILE UD/"DEMO.ALG_M AS DEMO/LIBRARY SL DEMO = (JAVA)OBJECT/DEMO/LIBRARY 2013 Unisys Corporation. All rights reserved. 15

Jii Development Process Demo LOCAL-STORAGE SECTION. $$INCLUDE JNICOB="COBOL" ("JNI-PARAMETERS") $$INCLUDE DEMOCOB="""DEMOINCL.C85_M""" ("DEMO-PARAMETERS") PROGRAM-LIBRARY SECTION. $$INCLUDE JNICOB="COBOL" ("JNI-FUNCTIONS") $$INCLUDE DEMOCOB="""DEMOINCL.C85_M""" ("DEMO-FUNCTIONS") PROCEDURE DIVISION. 2013 Unisys Corporation. All rights reserved. 16

Jii Development Process Demo Initialize-JVM. STRING jvmoptions, jvmcp1, jvmcp2, jvmcp3, jvmcp4 DELIMITED BY SIZE INTO ARGUMENTS. ADD FUNCTION Length ( jvmoptions ), FUNCTION Length ( jvmcp1 ), FUNCTION Length ( jvmcp2 ), FUNCTION Length ( jvmcp3 ), FUNCTION Length ( jvmcp4 ) GIVING ArgLength. MOVE MCP-Options TO Arguments-2. MOVE FUNCTION Length ( MCP-Options ) to Arg2Length. CALL JNI-CREATE-JAVA-VM USING JNI-VM, JNI-ENV, Interface-Version, ARGUMENTS, ArgLength ARGUMENTS-2, Arg2Length GIVING RESULT. CALL INITIALIZE-DEMO USING JNI-ENV. CALL DEMO-DEMO-GET-CONNECTION USING JNI-ENV, bresult. 2013 Unisys Corporation. All rights reserved. 17

Jii Development Process Demo OPEN INQUIRY UNIVERSEDB ON EXCEPTION GO TO XIT. loop-it. FIND WORD VIA NEXT IDX-WORDS ON EXCEPTION GO TO XIT. MOVE DMSII-WORD-A TO DataWord. MOVE WORD-SZ TO WordSz. CALL DEMO-DEMO-COMPARE-EQUAL USING JNI-ENV, WORD-ID, DataWord, WordSz, bresult. IF NOT bresult THEN DISPLAY "COMPARE STRING ERROR=", bresult. GO loop-it. xit. CLOSE UNIVERSEDB ON EXCEPTION NEXT SENTENCE. 2013 Unisys Corporation. All rights reserved. 18

Jii Possibilities? Calling Bouncy Castle Crypto API Accessing JBoss through its Java Naming and Directory Interface (JNDI) Accessing third-party databases Creating thumbnails of images PDF Generation Creating JSON data files Using off-the-shelf components written in Java http://www.componentsource.com/features/java-components/index.html 2013 Unisys Corporation. All rights reserved. 19

Guidelines for Calling Java Calling Java from native code is complicated and tedious. Crossing between MCP and the Java environment is expensive. Try to write heavy functions. Pass everything as parameters rather than calling back for more information. Stay in Java if you can; calling native code is seldom faster. 2013 Unisys Corporation. All rights reserved. 20

Java Docs Main Page Virtual Machine for the Java 6.0 Platform on ClearPath MCP Programming Guide Installation and Administration Guide ClearPath Common Appliance Configuration Guide JVM for MCP API Specification Java Native Interface for MCP Readme, Errata and Other Notes Optimizing Java Socket Performance Example Java Programs 2013 Unisys Corporation. All rights reserved. 21

A Cocktail of Java and MCP Using Java NIO2 Interfaces

Java 7 Java SE 7 Available with MCPJAVA in 15.0 New I/O features: Asynchronous I/O Ability to extend and customize the I/O interface. For MCP this means: Ability to query and specify many file attributes. 2013 Unisys Corporation. All rights reserved. 23

Java 7 Example import java.nio.file.*; import com.unisys.mcp.file.*; import static com.unisys.mcp.file.initialfileattributes.*; Path file = FileSystems.getDefault().getPath( args[0] ); file.createfile( FileKind.COBOL85SYMBOL.asFileAttribute(), FileClass.RECORDORIENTED.asFileAttribute(), maximumrecordsize(80), note("this file was created by Java") ); 2013 Unisys Corporation. All rights reserved. 24

Java 7 Example file.copyto( destination, StandardCopyOption.ReplaceExisting, McpCopyOption.Recursive, McpCopyOption.SourceHost( ECCSK ), Copies a file identified by the file path at ECCSK to the local host as the file identified by the destination path. Uses MCP copy operation (BNA, FTP). Similar moveto will change the file name, if possible; otherwise copy and delete the original. 2013 Unisys Corporation. All rights reserved. 25

McpFileAttributes Class Provides most MCP attributes for a file. All the various time stamps. Title Note and many more 2013 Unisys Corporation. All rights reserved. 26

File Attributes arealength accesstimestamp fileclass areas altertimestamp filekind blocksize attributemodifytimestamp filename clearareas backuptimestamp filestructure compilerkind copydestinationtimestamp framesize ccsversion copysourcetimestamp hostname extmode creationtimestamp licensekey familyindex executetimestamp note familyname opentimestamp pathname sensitivedata readtimestamp product userinfo maximumrecordsize title 2013 Unisys Corporation. All rights reserved. 27

Open Options Specify any of these when opening a file. File Options Buffers BufferSize HostName IntName Record Options Fold IncludeSequenceNumbers NoCrLf StripSpaces Truncate Unfold 2013 Unisys Corporation. All rights reserved. 28

Initial File Attributes Specify any of these when creating a file. arealength blocksize familyindex hostname note userinfo areas clearareas framesize maximumrecordsize sensitivedata 2013 Unisys Corporation. All rights reserved. 29

Java Docs Main Page Virtual Machine for the Java 6.0 Platform on ClearPath MCP Programming Guide Installation and Administration Guide ClearPath Common Appliance Configuration Guide JVM for MCP API Specification Java Native Interface for MCP Readme, Errata and Other Notes Optimizing Java Socket Performance Example Java Programs 2013 Unisys Corporation. All rights reserved. 30

A Cocktail of Java and MCP Accessing DMSII From Java

Accessing DMSII From Java DMSII Databases D M S Q L 2013 Unisys Corporation. All rights reserved. 32

Accessing DMSII From Java COBOL & ALGOL access via Host Language constructs OPEN, FIND/LOCK, CREATE, STORE, BEGIN-TRANSACTION, END-TRANSACTION, Java access Java Host Language Interface (JHLI) and Java DMInterface (JDMI) Java EE Connector Architecture (JCA) components Resource Adapters MCP Transaction Resource Adapter (JRAC) Open Distributed Transaction Processing Resource Adapter (DTP-RA) Java Database Connectivity (JDBC) Resource adapters based on JCA Structured Query Language (SQL) based Hibernate 2013 Unisys Corporation. All rights reserved. 33

Querying DMSII using JDBC SQL Client Tools DMSII 2013 Unisys Corporation. All rights reserved. 34

JDBC Driver DMSII-JDBC @ GSA ClearPath JProcessor MCP Presentation Tier/ Business Tier JSF/RichFaces POJO SQL Query Processor for ClearPath MCP DMSII 2013 Unisys Corporation. All rights reserved. 35

Summary Invocation interface lets ALGOL or COBOL program call Java libraries. Java 7 will allow tighter file system integration. Consider the alternatives for accessing a DMSII database from Java 2013 Unisys Corporation. All rights reserved. 36

Questions? 2013 Unisys Corporation. All rights reserved. 37