Chapter 3 DB-Gateways

Similar documents
Chapter 3 DB-Gateways

Chapter 3 DB-Gateways

Chapter 3 DB-Gateways

Chapter 2 Distributed Information Systems Architecture

Chapter 4 Remote Procedure Calls and Distributed Transactions

Chapter 11 Web-based Information Systems

COP4020 Programming Languages. Compilers and Interpreters Prof. Robert van Engelen

Outline n Introduction n Background o Distributed DBMS Architecture

Architectural styles for software systems The client-server style

Chapter 8 Web Services Foundations

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Chapter 5 Application Server Middleware

CMSC Computer Architecture Lecture 12: Virtual Memory. Prof. Yanjing Li University of Chicago

Service Oriented Enterprise Architecture and Service Oriented Enterprise

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

1 Enterprise Modeler

Today s objectives. CSE401: Introduction to Compiler Construction. What is a compiler? Administrative Details. Why study compilers?

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

JDBC (Java Database Connectivity)

Software development of components for complex signal analysis on the example of adaptive recursive estimation methods.

Goals of the Lecture UML Implementation Diagrams

Baan Tools User Management

BEA Tuxedo. Creating CORBA Client Applications

SCI Reflective Memory

COSC 1P03. Ch 7 Recursion. Introduction to Data Structures 8.1

Chapter 4 Threads. Operating Systems: Internals and Design Principles. Ninth Edition By William Stallings

Security and Communication. Ultimate. Because Intercom doesn t stop at the hardware level. Software Intercom Server for virtualised IT platforms

Chapter 10. Defining Classes. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Τεχνολογία Λογισμικού

Customer Portal Quick Reference User Guide

n Explore virtualization concepts n Become familiar with cloud concepts

VISUALSLX AN OPEN USER SHELL FOR HIGH-PERFORMANCE MODELING AND SIMULATION. Thomas Wiedemann

Code Review Defects. Authors: Mika V. Mäntylä and Casper Lassenius Original version: 4 Sep, 2007 Made available online: 24 April, 2013

Outline. Research Definition. Motivation. Foundation of Reverse Engineering. Dynamic Analysis and Design Pattern Detection in Java Programs

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

CS 11 C track: lecture 1

Avid Interplay Bundle

Session Initiated Protocol (SIP) and Message-based Load Balancing (MBLB)

Elementary Educational Computer

Keywords Software Architecture, Object-oriented metrics, Reliability, Reusability, Coupling evaluator, Cohesion, efficiency

Classes and Objects. Again: Distance between points within the first quadrant. José Valente de Oliveira 4-1

Structuring Redundancy for Fault Tolerance. CSE 598D: Fault Tolerant Software

Python Programming: An Introduction to Computer Science

System and Software Architecture Description (SSAD)

Goals of this Lecture Activity Diagram Example

Isn t It Time You Got Faster, Quicker?

Towards Efficient Selection of Web Services

Computers and Scientific Thinking

Behavioral Modeling in Verilog

Python Programming: An Introduction to Computer Science

Multi-Threading. Hyper-, Multi-, and Simultaneous Thread Execution

Loop Emulation Service Protocols over ATM. Enea LES-SIG-Bricks is a complete implementation of the Loop Emulation

MOTIF XF Extension Owner s Manual

Extending The Sleuth Kit and its Underlying Model for Pooled Storage File System Forensic Analysis

CS 111: Program Design I Lecture 19: Networks, the Web, and getting text from the Web in Python

Chapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Adapter for Mainframe

BEA Tuxedo. Using the BEA Tuxedo System on Windows NT

Last class. n Scheme. n Equality testing. n eq? vs. equal? n Higher-order functions. n map, foldr, foldl. n Tail recursion

Package RcppRoll. December 22, 2014

Bayesian approach to reliability modelling for a probability of failure on demand parameter

Schema for the DCE Security Registry Server

Generic Model Management: Experiences and Open Questions

Baan Finance Financial Statements

Chapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

implement language system

3.1 Overview of MySQL Programs. These programs are discussed further in Chapter 4, Database Administration. Client programs that access the server:

Panel for Adobe Premiere Pro CC Partner Solution

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 4. The Processor. Single-Cycle Disadvantages & Advantages

OPC Server ECL Comfort 210/310 OPC Server

From last week. Lecture 5. Outline. Principles of programming languages

CS : Programming for Non-Majors, Summer 2007 Programming Project #3: Two Little Calculations Due by 12:00pm (noon) Wednesday June

Chapter 8. Strings and Vectors. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

10/23/18. File class in Java. Scanner reminder. Files. Opening a file for reading. Scanner reminder. File Input and Output

Kyle Brown Knowledge Systems Corporation by Kyle Brown and Knowledge Systems Corporation

Chapter 13 Introduction to SQL Programming Techniques

Basic allocator mechanisms The course that gives CMU its Zip! Memory Management II: Dynamic Storage Allocation Mar 6, 2000.

Workflow model GM AR. Gumpy. Dynagump. At a very high level, this is what gump does. We ll be looking at each of the items described here seperately.

Compiling and executing managed code

n We have discussed classes in previous lectures n Here, we discuss design of classes n Library design considerations

BEA WebLogic Application Integration A Component of BEA WebLogic Integration. Adapter Development Guide

Chapter 4 Application Programs and Object-Relational Capabilities

802.1ad Provider & Provider Edge Bridges

Chapter 4. Procedural Abstraction and Functions That Return a Value. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

Data diverse software fault tolerance techniques

Morgan Kaufmann Publishers 26 February, COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 5.

Chapter 8. Strings and Vectors. Copyright 2015 Pearson Education, Ltd.. All rights reserved.

EE 459/500 HDL Based Digital Design with Programmable Logic. Lecture 13 Control and Sequencing: Hardwired and Microprogrammed Control

CSC 220: Computer Organization Unit 11 Basic Computer Organization and Design

Getting Started. Getting Started - 1

Topics. Instance object. Instance object. Fundamentals of OT. Object notation. How do objects collaborate? Pearson Education 2007 Appendix (RASD 3/e)

CS200: Hash Tables. Prichard Ch CS200 - Hash Tables 1

CA Top Secret r14 for z/os

BEA Tuxedo. Introducing the BEA Tuxedo System

Threads and Concurrency in Java: Part 1

Overview. Database Application Development. SQL in Application Code. SQL in Application Code (cont.)

Database Application Development

Database Application Development

Out the box. dataloggers. easy to configure easy data streaming easy choice. connect, simply configure and go

Transcription:

Prof. Dr.-Ig. Stefa Deßloch AG Heterogee Iformatiossysteme Geb. 36, Raum 329 Tel. 0631/205 3275 dessloch@iformatik.ui-kl.de Chapter 3 DB-Gateways

Outlie Couplig DBMS ad programmig laguages approaches requiremets Programmig Model (JDBC) overview DB coectio model trasactios DB-Gateways architectures ODBC JDBC SQL/OLB embedded SQL i Java Summary Prof.Dr.-Ig. Stefa Deßloch 2 Middleware for Heterogeeous ad Distributed Iformatio Systems

Static Embedded SQL Static SQL queries are embedded i the programmig laguage programmig laguage is "exteded", usig prefix for SQL operatios cursors to bridge so-called impedace mismatch (sets of results) host variables for query parameters ad results Example: exec sql declare c cursor for SELECT empo FROM Employees WHERE dept = :depto_var; exec sql ope c; exec sql fetch c ito :empo_var; Preprocessor/precompiler coverts SQL ito fuctio calls of the programmig laguage potetial performace advatages (early query compilatio) vedor-specific precompiler ad target iterface fuctio calls ivoke DBMS-specific APIs iitial source code is (usually) portable, but code resultig from precompilatio is ot! Prof.Dr.-Ig. Stefa Deßloch 3 Middleware for Heterogeeous ad Distributed Iformatio Systems

Dyamic Embedded SQL SQL queries ca be created dyamically by the program character strigs iterpreted as SQL statemets by a SQL system Example: strcpy(stmt, "SELECT empo FROM Employees WHERE dept =?"); exec sql prepare s1 from :stmt; exec sql declare c cursor for s1; exec sql ope c usig :depto_var; exec sql fetch c ito :empo_var; Preprocessor is still required oly late query compilatio same drawbacks regardig portability as for static embedded Prof.Dr.-Ig. Stefa Deßloch 4 Middleware for Heterogeeous ad Distributed Iformatio Systems

Call-Level Iterface (CLI) Stadard library of fuctios that ca be liked to the program Same capabilities as (dyamic) embedded SQL queries are strig parameters of fuctio ivocatios Example: strcpy(stmt, "SELECT empo FROM Employees WHERE dept =?"); SQLPrepare(st_hadle, stmt, ); SQLBidParam(st_hadle, 1,, &depto_var, ); SQLBidCol(st_hadle, 1,, &empo_var, ); SQLExecute(st_hadle); SQLFetch(st_hadle); Avoids vedor-specific precompiler, allows to write/produce biary-portable programs Prof.Dr.-Ig. Stefa Deßloch 5 Middleware for Heterogeeous ad Distributed Iformatio Systems

Stadard Call Level Iterfaces - Requiremets Uiform database access query laguage (SQL) meta data (both query results ad DB-schema) Alterative: SQL Iformatio Schema programmig iterface Portability call level iterface (CLI) o vedor-specific pre-compiler applicatio biaries are portable but: icreased applicatio complexity dyamic bidig of vedor-specific ru-time libraries Dyamic, late bidig to specific DB/DBS late query compilatio flexibility vs. performace Prof.Dr.-Ig. Stefa Deßloch 6 Middleware for Heterogeeous ad Distributed Iformatio Systems

Additioal Requiremets for DB-Gateways Remote data access Multiple simultaeously active DB-coectios withi the same applicatio thread to the same DB to differet DBs withi the same (distributed) trasactio Simultaeous access to multiple DBMS architecture supports use of (multiple) DBMS-specific drivers coordiated by a driver maager Support for vedor-specific extesios distributed TA DBS1 cliet P T DB gateway DBS2 DB1 DB2 DB3 presetatio applicatio logic resource maagemet DBS3 Prof.Dr.-Ig. Stefa Deßloch 7 Middleware for Heterogeeous ad Distributed Iformatio Systems

Historical Developmet ODBC: Ope Database Coectivity itroduced i 1992 by Microsoft quickly became a de-facto stadard ODBC drivers available for almost ay DBMS "blueprit" for ISO SQL/CLI stadard JDBC itroduced i 1997, iitially defied by SUN, based o ODBC approach leverages advatages of Java (compared to C) for the API abstractio layer betwee Java programs ad SQL curret versio: JDBC 4.1 (July 2011) Java applicatio JDBC 4.1 SQL-92, SQL:1999, SQL:2003 (object-) relatioal DBS Prof.Dr.-Ig. Stefa Deßloch 8 Middleware for Heterogeeous ad Distributed Iformatio Systems

JDBC Core Iterfaces Coectio default: <source>.<method> -> <target> createstatemet preparestatemet preparecall subclass subclass Statemet PreparedStatemet CallableStatemet IN: PreparedStatemet. setxxx IN/OUT/INOUT: CallableStatemet. getxxx/setxxx executequery Data Types executequery getxxx getresultset getmoreresults ResultSet Prof.Dr.-Ig. Stefa Deßloch 9 Middleware for Heterogeeous ad Distributed Iformatio Systems

Example: JDBC Strig url = "jdbc:db2:mydatabase"; Coectio co = DriverMaager.getCoectio(url, "dessloch", "pass"); Strig sqlstr = "SELECT * FROM Employees WHERE dept = 1234"; Statemet stmt = co.createstatemet( ); ResultSet rs = stmt.executequery(sqlstr); while (rs.ext() ) { Strig a = rs.getstrig(1); Strig str = rs.getstrig(2); System.out.prit(" empo= " + a); System.out.prit(" firstame= " + str); System.out.prit("\"); } Prof.Dr.-Ig. Stefa Deßloch 10 Middleware for Heterogeeous ad Distributed Iformatio Systems

JDBC Processig Query Results ResultSet getxxx-methods scrollable ResultSets updatable ResultSets Data types coversio fuctios streams to support large data values with JDBC 2.0 came support of SQL:1999 data types LOBS (BLOBS, CLOBS) arrays user-defied data types refereces Prof.Dr.-Ig. Stefa Deßloch 11 Middleware for Heterogeeous ad Distributed Iformatio Systems

JDBC Additioal Fuctioality Metadata methods for metadata lookup importat for geeric applicatios Exceptio Hadlig SQLExceptio class (hierarchy) carries SQL error code, descriptio Itegrated with Java (chaied) exceptio hadlig Batch Updates multiple statemets ca be submitted at oce to improve performace RowSets... Ca hold a (discoected) copy of a result set Modificatios ca be buffered ad explicitly sychoized with the database later Prof.Dr.-Ig. Stefa Deßloch 12 Middleware for Heterogeeous ad Distributed Iformatio Systems

No Trasactios i JDBC Coectio iterface trasactio-orieted methods for local TAs begi is implicit commit() rollback() get/settrasactioisolatio() NONE, READ_UNCOMMITTED, READ_COMMITTED, REPEATABLE_READ, SERIALIZABLE get/setautocommit() Here, the scope of the trasactio is a sigle coectio! support for distributed trasactios is provided usig additioal extesios, iteractios with a trasactio maager (see subsequet chapters) same i ODBC Prof.Dr.-Ig. Stefa Deßloch 13 Middleware for Heterogeeous ad Distributed Iformatio Systems

DB Gateway Architecture Applicatios Driver programs usig DB-CLI fuctioality usage coect to data sources execute SQL statemets (e.g., queries) over data sources receive (ad process) results processes CLI calls hides heterogeeity of data sources may traslate SQL to vedor-specific dialect commuicates SQL requests to DBMS Alterative: does the etire processig of the SQL requests Driver Maager maages iteractios betwee applicatios ad drivers realizes (:m)-relatioship betwee applicatios ad drivers tasks load/uload driver mappig data sources to drivers commuicatio/loggig of fuctio/method calls simple error hadlig applicatio driver maager Oracle driver DB2 driver O/JDBC API Prof.Dr.-Ig. Stefa Deßloch 14 Middleware for Heterogeeous ad Distributed Iformatio Systems

Driver Maager Tasks applicatio coect driver maager applicatio request XYZ driver maager applicatio discoect driver maager mappig data source-> driver o driver loaded? yes ot OK error detectio OK o driver still eeded? yes load driver driver request XYZ driver uload driver driver ODBC oly! Prof.Dr.-Ig. Stefa Deßloch 15 Middleware for Heterogeeous ad Distributed Iformatio Systems

Driver Tasks ad Resposibilities Coectio Maagemet Error hadlig stadard error fuctios/codes/messages,... Traslatio of SQL requests if sytax of DBMS deviates from stadard SQL Data type mappig Meta data fuctios access (proprietary) system catalogs Iformatio fuctios provide iformatio about driver (self), data sources, supported data types ad DBMS capabilities Optio fuctios Parameter for coectios ad statemets (e.g., statemet executio timeout) Prof.Dr.-Ig. Stefa Deßloch 16 Middleware for Heterogeeous ad Distributed Iformatio Systems

Realizatio Alteratives ODBC driver types oe-tier two-tier three-tier JDBC driver types Type 1: JDBC-ODBC bridge Type 2: Part Java, Part Native Type 3: Itermediate DB Access Server Type 4: Pure Java Applicatio does ot "see" realizatio alteratives! Prof.Dr.-Ig. Stefa Deßloch 17 Middleware for Heterogeeous ad Distributed Iformatio Systems

Sigle-Tier Driver Used to access flat files, ISAM files, desktop databases accessig flat files accessig ISAM files or desktop DBs Data resides o the same machie as the driver Fuctioality: complete SQL processig (parse, optimize, execute) applicatio driver maager driver applicatio driver maager driver egie calls ofte lacks multi-user ad trasactio support file I/O calls ISAM/DTDB egie file I/O calls file system file system Prof.Dr.-Ig. Stefa Deßloch 18 Middleware for Heterogeeous ad Distributed Iformatio Systems

Two-Tier Driver Classical cliet/server support driver acts as a cliet iteractig with DBMS (server) through data protocol Implemetatio alteratives 1. direct data protocol support 2. mappig ODBC to DBMS-cliet API 3. middleware solutio Direct data protocol support applicatio driver maager two-tier driver data protocol cliet (1) Direct data protocol support message-based or RPC-based utilizes DBMS-specific etwork libraries or RPC rutime etwork libraries or RPC rutime etwork data protocol DBMS server Prof.Dr.-Ig. Stefa Deßloch 19 Middleware for Heterogeeous ad Distributed Iformatio Systems

Two-Tier Driver (cotiued) (2) Mappig to DBMS-cliet API (3) Middleware solutio cliet cliet applicatio driver maager two-tier driver DBS-cliet API DBS rutime library data protocol etwork libraries or RPC rutime etwork data protocol DBMS applicatio driver maager two-tier driver (MW-vedor) etwork library or RPC rutime (middleware vedor) etwork data protocol (MW vedor) server applicatio (middleware vedor) DBS rutime library DBMS server server Prof.Dr.-Ig. Stefa Deßloch 20 Middleware for Heterogeeous ad Distributed Iformatio Systems

Three-Tier Driver Middleware Server gateway server cliet applicatio coects ad relays requests to oe or more DBMS servers Moves the complexity from the cliet to the middleware server cliet requires oly a sigle driver (for the middleware server) Arbitrary umber of tiers possible middleware server driver maager three-tier driver etwork lib./rpc rutime data protocol 1 DB request server driver maager two-tier driver addtl. compoets data protocol 2 server DBMS Prof.Dr.-Ig. Stefa Deßloch 21 Middleware for Heterogeeous ad Distributed Iformatio Systems

JDBC Driver Types Partial Java (requires ative biaries o cliet) Type 1: JDBC-ODBC bridge 2-tier mappig to ODBC API uses Java Native Iterface (JNI) Type 2: Native-API Partial-Java driver 2-tier uses a ative DBMS cliet library All-Java (does ot require ative biaries o cliet) Type 3: Net-Protocol All-Java driver 3-tier driver o cliet is pure Java commuicates with JDBC server/gateway Type 4: Native-Protocol All-Java driver 2-tier pure Java implemets the etwork data protocol of the DBMS directly coects to the data source Prof.Dr.-Ig. Stefa Deßloch 22 Middleware for Heterogeeous ad Distributed Iformatio Systems

SQL Object Laguage Bidigs (OLB) aka SQLJ Part 0 Static, embedded SQL i Java Developmet advatages over JDBC more cocise, easier to code static type checkig, error checkig at precompilatio time Permits static authorizatio Ca be used i cliet code ad stored procedures Goal: SQLJ traslator/customizer framework supports biary compatibility (ulike traditioal embedded SQL) SQLJ traslator implemeted usig JDBC produces statemet profiles vedor-specific customizers ca add differet implemetatio, to be used istead of default produced by traslator potetial performace beefits resultig biary cotais default ad possibly multiple customized implemetatios Iteroperability with JDBC combied use of SQLJ with JDBC for flexibility Prof.Dr.-Ig. Stefa Deßloch 23 Middleware for Heterogeeous ad Distributed Iformatio Systems

SQL/OLB Static SQL authorizatio optio Static SQL is associated with "program" Plas/packages idetify "programs" to DB Program author's table privileges are used dyamic SQL static SQL check authorizatio for package Users are grated EXECUTE o program Dyamic SQL is associated with "user" No otio of "program" parse SQL statemet Ed users must have table privileges BIG PROBLEM FOR A LARGE ENTERPRISE!!! Static SQL sytax for Java check table/view authorizatio INSERT, UPDATE, DELETE, CREATE, GRANT, etc. calculate access path Sigleto SELECT ad cursor-based SELECT Calls to stored procedures (icludig result sets) execute statemet execute statemet COMMIT, ROLLBACK Methods for CONNECT, DISCONNECT Prof.Dr.-Ig. Stefa Deßloch 24 Middleware for Heterogeeous ad Distributed Iformatio Systems

SQL/OLB vs. JDBC: Retrieve Sigle Row SQL OLB #sql [co] { SELECT ADDRESS INTO :addr FROM EMP WHERE NAME=:ame }; JDBC java.sql.preparedstatemet ps = co.preparestatemet( "SELECT ADDRESS FROM EMP WHERE NAME=?"); ps.setstrig(1, ame); java.sql.resultset ames = ps.executequery(); ames.ext(); ame = ames.getstrig(1); ames.close(); Prof.Dr.-Ig. Stefa Deßloch 25 Middleware for Heterogeeous ad Distributed Iformatio Systems

Result Set Iterators Mechaism for accessig the rows retured by a query Comparable to a SQL cursor Iterator declaratio clause results i geerated iterator class Iterator is a Java object Iterators are strogly typed Geeric methods for advacig to ext row Assigmet clause assigs query result to iterator Two types of iterators Named iterator Positioed iterator Prof.Dr.-Ig. Stefa Deßloch 26 Middleware for Heterogeeous ad Distributed Iformatio Systems

Named Iterators - Example Geerated iterator class has accessor methods for each result colum #sql iterator Hoors ( Strig ame, float grade ); Hoors hoor; #sql [recs] hoor = { SELECT SCORE AS "grade", STUDENT AS "ame" FROM GRADE_REPORTS WHERE SCORE >= :limit AND ATTENDED >= :days ORDER BY SCORE DESCENDING }; while (hoor.ext()) { System.out.pritl( hoor.ame() + " has grade " + hoor.grade() ); } Prof.Dr.-Ig. Stefa Deßloch 27 Middleware for Heterogeeous ad Distributed Iformatio Systems

Positioed Iterator Use FETCH statemet to retrieve result colums ito host variables based o positio #sql iterator Hoors ( Strig, float ); Hoors hoor; Strig ame; float grade; #sql [recs] hoor = { SELECT STUDENT, SCORE FROM GRADE_REPORTS WHERE SCORE >= :limit AND ATTENDED >= :days ORDER BY SCORE DESCENDING }; while (true) { #sql {FETCH :hoor INTO :ame, :grade }; if (hoor.edfetch()) break; System.out.pritl( ame + " has grade " + grade ); } Prof.Dr.-Ig. Stefa Deßloch 28 Middleware for Heterogeeous ad Distributed Iformatio Systems

SQLJ - Biary Portability Java as a platform-idepedet laguage Use of geeric SQLJ-precompiler/traslator (avoids DBMS-specific precompiler techology) Geerated code uses stadard JDBC by default Compiled SQLJ applicatio (Java byte code) is portable Customizer techology allows DBMS-specific optimizatios after the compilatio SQLJ source class ABC { #sql SELECT... } Geeric SQLJ traslator SQLJ source class ABC { call "stub" } Java Compiler Java byte codes Extracted SQL Optioal step: DBMS-specific customizer Java byte codes Extracted SQL SELECT... host var data SELECT... host var data Extracted SQL SELECT... host var data JDBC default "stub" JDBC "stub" Most vedors use default JDBC "stub" JDBC "stub" DBMS-specific "stub" Prof.Dr.-Ig. Stefa Deßloch 29 Middleware for Heterogeeous ad Distributed Iformatio Systems

Summary Couplig approaches static ad dyamic embedded SQL call-level iterface (CLI) Gateways JDBC SQLJ ODBC / JDBC support uiform, stadardized access to heterogeeous data sources ecapsulate/hide vedor-specific aspects multiple, simultaeously active coectios to differet databases ad DBMSs driver/driver maager architecture eabled for distributed trasactio processig (see subsequet chapters) high acceptace importat ifrastructure for realizig IS distributio at DB-operatio level o support for data source itegratio 'for Java, i Java importat basis for data access i Java-based middleware (e.g., J2EE) combies advatages of embedded SQL with biary portability, vedor-idepedece Prof.Dr.-Ig. Stefa Deßloch 30 Middleware for Heterogeeous ad Distributed Iformatio Systems