Chapter   INTRODUCTION
  1




          SYS-ED/
          Computer
          Education
          Techniques, Inc.
DB2 UDB Prg in JAVA with JDBC                                Introduction

Objectives

You will learn:

    UDB tools.
   ...
DB2 UDB Prg in JAVA with JDBC                                                               Introduction


               ...
DB2 UDB Prg in JAVA with JDBC                                                           Introduction



                  ...
DB2 UDB Prg in JAVA with JDBC                                                     Introduction


                         ...
DB2 UDB Prg in JAVA with JDBC                                                              Introduction


                ...
DB2 UDB Prg in JAVA with JDBC                                                                Introduction


              ...
DB2 UDB Prg in JAVA with JDBC                                                             Introduction


                 ...
DB2 UDB Prg in JAVA with JDBC                                                          Introduction


                    ...
DB2 UDB Prg in JAVA with JDBC                                                               Introduction


               ...
DB2 UDB Prg in JAVA with JDBC                                                                  Introduction


            ...
DB2 UDB Prg in JAVA with JDBC                                                        Introduction


                      ...
DB2 UDB Prg in JAVA with JDBC                                                         Introduction


                     ...
DB2 UDB Prg in JAVA with JDBC                                                                Introduction


              ...
DB2 UDB Prg in JAVA with JDBC                                                              Introduction


                ...
DB2 UDB Prg in JAVA with JDBC                                                              Introduction


                ...
Upcoming SlideShare
Loading in...5
×

Instructions for Installing DB2 Developers Edition Products

436

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
436
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Instructions for Installing DB2 Developers Edition Products"

  1. 1. Chapter INTRODUCTION 1 SYS-ED/ Computer Education Techniques, Inc.
  2. 2. DB2 UDB Prg in JAVA with JDBC Introduction Objectives You will learn: UDB tools. DB2 programming interfaces. Host language and embedded SQL. Embedded SQL. DB2 Call Level Interface. JDBC: Java Database Connectivity. JDBC drivers. Embedded SQL for Java (SQLj). XML Extender. DB2 programming features. DB2 stored procedures. DB2 user-defined functions and methods. SYS-ED/COMPUTER EDUCATION TECHNIQUES, INC. (DB2JDBC - 3.4) Ch 1: Page i
  3. 3. DB2 UDB Prg in JAVA with JDBC Introduction 1.1 UDB Tools Tool Description Control Graphical interface that displays database objects such as databases, tables, and Center packages and their relationship to each other. It is used for performing administrative tasks such as configuring the system, managing directories, backing up and recovering the system, scheduling jobs, and managing media. Command Used to enter DB2 commands and SQL statements in an interactive window, and to Center see the execution result in a result window. The results can be scrolled and the output saved to a file. Script Used for creating scripts, which can be stored and invoked at a later time. These Center scripts can contain DB2 commands, SQL statements, or operating system commands. Scripts can scheduled to run unattended. Alert Used to monitor the system for early warnings of potential problems, or to automate Center actions to correct problems. Tools Used to change the settings for the Control Center, Alert Center, and Replication. Setting Event Collects performance information on database activities over a period of time. Monitor Visual An installable option for the Control Center, Visual Explain is a graphical interface that Explain provides for the analysis and tuning of SQL statements. SYS-ED/COMPUTER EDUCATION TECHNIQUES, INC. (DB2JDBC - 3.4) Ch 1: Page 1
  4. 4. DB2 UDB Prg in JAVA with JDBC Introduction 1.2 DB2 Supported Programming Interfaces Several different programming interfaces can be used for managing or accessing DB2 databases. DB2 APIs can be used for performing administrative functions such as backing up and restoring databases. Static and dynamic SQL statements can be embedded in applications. DB2 Call Level Interface (DB2 CLI) function calls can be coded in applications to invoke dynamic SQL statements. Java applications and applets can be developed that call the Java Database Connectivity application programming interface (JDBC API). Visual Basic and Visual C++ applications can be developed which conform to Data Access Object (DAO) and Remote Data Object (RDO) specifications and ActiveX Data Object (ADO) applications that use the Object Linking and Embedding Database (OLE DB) Bridge. Applications can be developed using IBM or third-party tools such as Net.Data, Excel, Perl, and Open Database Connectivity (ODBC) end-user tools such as Lotus Approach, and its programming language, LotusScript. SYS-ED/COMPUTER EDUCATION TECHNIQUES, INC. (DB2JDBC - 3.4) Ch 1: Page 2
  5. 5. DB2 UDB Prg in JAVA with JDBC Introduction 1.3 Programming Issues Programmers will need to control data values and the relationship between data. Data values can be controlled using: Data types (built-in or user-defined) Table check constraints Referential integrity constraints Views using the CHECK OPTION Application logic and variable types The relationship between data values can be controlled using: Referential integrity constraints Triggers Application logic Programs can be executed at the server using: Stored procedures User-defined functions Triggers SYS-ED/COMPUTER EDUCATION TECHNIQUES, INC. (DB2JDBC - 3.4) Ch 1: Page 3
  6. 6. DB2 UDB Prg in JAVA with JDBC Introduction 1.4 DB2 Application Programming Interfaces A typical application will need to perform some database administration tasks, such as creating, activating, backing up, or restoring a database. DB2 provides numerous APIs for performing these tasks from an applications; the two most prominent being embedded SQL and DB2 CLI applications. This will allow the programmer to include administrative functions into applications thereby providing the same functionality as the DB2 server administration tools available in the Control Center. There are some tasks that can only be performed using the DB2 APIs. SYS-ED/COMPUTER EDUCATION TECHNIQUES, INC. (DB2JDBC - 3.4) Ch 1: Page 4
  7. 7. DB2 UDB Prg in JAVA with JDBC Introduction 1.5 Host Language and Embedded SQL Structured Query Language (SQL) is the database interface language used to access and manipulate data in DB2 databases. SQL statements can be embedded in applications, enabling them to perform any task supported by SQL, such as retrieving or storing data. DB2 can be used for embedding SQL applications in the C/C++, COBOL, FORTRAN, Java (SQLj), and REXX programming languages. Hosts Program and Host Language An application in which SQL statements are embedded is a host program. The programming language used for creating a host program is called a host language. Static Statements and Dynamic Statements For static SQL statements, the SQL statement type and the table and column names will be known prior to compile time. The only unknowns are specific data values the statement is searching for or updating. These values can be represented in the host language variables. SQL statements will need to be precompiled, bound, and then compiled before the application can be run. Static SQL is best run on databases whose statistics are relatively stagnant. If this is not the case, the statements will soon get out of date. Dynamic SQL statements are used for application builds and execute at run time. The application builds the SQL statement while it’s running, and then submits the statement for processing. Applications can be written that have static SQL statements, dynamic SQL statements, or a mix of both. Static SQL statements are well-suited for high-performance applications with predefined transactions. Dynamic SQL statements are well-suited for applications that run against a rapidly changing database where transactions need to be specified at run time. SYS-ED/COMPUTER EDUCATION TECHNIQUES, INC. (DB2JDBC - 3.4) Ch 1: Page 5
  8. 8. DB2 UDB Prg in JAVA with JDBC Introduction 1.6 Embedded SQL When embedding SQL statements in an application, it will be necessary to precompile and bind an application to a database with the following steps: 1. Create source files that contain programs with embedded SQL statements. 2. Connect to a database, and then precompile each source file. 3. Compile the modified source files (and other files without SQL statements) using the host language compiler. 4. Link the object files with the DB2 and host language libraries to produce an executable program. 5. Bind the bind file to create the access package if this was not already done at precompile time, or if a different database is going to be accessed. 6. Run the application. The application accesses the database using the access plan in the package. SYS-ED/COMPUTER EDUCATION TECHNIQUES, INC. (DB2JDBC - 3.4) Ch 1: Page 6
  9. 9. DB2 UDB Prg in JAVA with JDBC Introduction 1.7 DB2 Call Level Interface DB2 CLI is a programming interface that C and C++ applications can use to access DB2 databases. DB2 CLI is based on the Microsoft Open Database Connectivity (ODBC) specification, and the ISO CLI standard. When using DB2 CLI, an application passes dynamic SQL statements as function arguments to the database manager for processing. DB2 CLI is an alternative to embedded dynamic SQL. It is also possible to run the SQL statements as static SQL in a CLI, ODBC or JDBC application. An ODBC application can be built without using an ODBC driver manager, and the DB2’s ODBC driver can be used on any platform by linking an application with libdb2 on UNIX, and db2cli.lib on Windows operating systems. It will not be necessary to precompile or bind DB2 CLI applications because they use common access packages provided with DB2. An application can be compiled and linked. However, before a DB2 CLI or ODBC application can access DB2 databases, the DB2 CLI bind files that come with the DB2 AD client must be bound to each DB2 database that will be accessed. SYS-ED/COMPUTER EDUCATION TECHNIQUES, INC. (DB2JDBC - 3.4) Ch 1: Page 7
  10. 10. DB2 UDB Prg in JAVA with JDBC Introduction 1.8 JDBC: Java Database Connectivity DB2’s Java support includes JDBC, a vendor-neutral dynamic SQL interface that provides data access to an application through standardized Java methods. JDBC is similar to DB2 CLI in that it will not be necessary to precompile or bind a JDBC program. As a vendor-neutral standard, JDBC applications offer increased portability. An application written using JDBC uses only dynamic SQL. JDBC can be especially useful for accessing DB2 databases across the Internet. The Java programming language, can be used for developing JDBC applets and applications that access and manipulate data in remote DB2 databases using a network connection. JDBC stored procedures can be created that reside on the server, access the database server, and return information to a remote client application that calls the stored procedure. The JDBC API, is similar to the CLI/ODBC API, provides a standard way to access databases from Java code. The Java code passes SQL statements as method arguments to the DB2 JDBC driver. The driver handles the JDBC API calls from the client Java code. Java’s portability enables DB2 access to be delivered to clients on multiple platforms, requiring only a Java-enabled web browser, or a Java runtime environment. SYS-ED/COMPUTER EDUCATION TECHNIQUES, INC. (DB2JDBC - 3.4) Ch 1: Page 8
  11. 11. DB2 UDB Prg in JAVA with JDBC Introduction 1.9 JDBC Drivers JDBC Type 2 Java applications based on the JDBC type 2 driver rely on the DB2 client to connect to DB2. An application is started from the desktop or command line. The DB2 JDBC driver handles the JDBC API calls from the application, and uses the client connection to communicate the requests to the server and to receive the results. Java applets can not be created using the JDBC type 2 driver. The JDBC type 2 driver is recommended for WebSphere Application Servers. JDBC Type 3 When the JDBC type 3 driver is used, only Java applets can be created. Java applets do not require the DB2 client to be installed on the client machine. Typically, you would embed the applet in a web page. To run an applet based on the JDBC type 3 driver, a Java-enabled web browser or applet viewer is required on the client machine. When loading a HTML page, the browser downloads the Java applet to the machine, which then downloads the Java class files and DB2’s JDBC driver. JDBC Type 4 The JDBC type 4 driver, is new for Version 8, and is used for creating both Java applications and applets. To run an application or an applet that is based on the type 4 driver, only the db2jcc.jar file is required. No DB2 client is required. SYS-ED/COMPUTER EDUCATION TECHNIQUES, INC. (DB2JDBC - 3.4) Ch 1: Page 9
  12. 12. DB2 UDB Prg in JAVA with JDBC Introduction 1.10 Embedded SQL for Java (SQLj) DB2 Java embedded SQL (SQLj) support is provided by the DB2 AD Client. With DB2 SQLj support, in addition to DB2 JDBC support, a programmer can build and run SQLj applets, applications, and stored procedures. These contain static SQL and use embedded SQL statements that are bound to a DB2 database. SYS-ED/COMPUTER EDUCATION TECHNIQUES, INC. (DB2JDBC - 3.4) Ch 1: Page 10
  13. 13. DB2 UDB Prg in JAVA with JDBC Introduction 1.11 XML Extender Extensible Markup Language (XML) is the accepted standard technique for data exchange between applications. An XML document is a tagged document which is human-legible. The text consists of character data and markup tags. The markup tags are definable by the author of the document. A Document Type Definition (DTD) is used to declare the markup definitions and constraints. DB2 XML Extender gives a mechanism for programs to manipulate XML data using SQL extensions. The DB2 XML Extender introduces three new data types: XMLVARCHAR XMLCLOB XMLFILE The extender provides UDFs to store, extract and update XML documents located within single or multiple columns and tables. Searching can be performed on the entire XML document or based on structural components using the location path, which uses a subset of the Extensible Stylesheet Language Transformation (XSLT) and XPath for XML Path Language. To facilitate storing XML documents as a set of columns, the DB2 XML Extender provides an administration tool to aid the designer with XML-to-relational database mapping. The Document Access Definition (DAD) is used to maintain the structural and mapping data for the XML documents. The DAD is defined and stored as an XML document, which makes it simple to manipulate and understand. SYS-ED/COMPUTER EDUCATION TECHNIQUES, INC. (DB2JDBC - 3.4) Ch 1: Page 11
  14. 14. DB2 UDB Prg in JAVA with JDBC Introduction 1.12 DB2 Programming Features DB2 comes with a variety of features that run on the server which can be used to supplement or extend applications. When using DB2 features, it will not be necessary to write code to perform the same tasks. DB2 also provides for some parts of code to be stored at the server instead of keeping all of it in the client application. This can have performance and maintenance benefits. Features have been included to protect data and define relationships between data. There are object- relational features to create flexible, advanced applications. The key DB2 features are: Constraints User-defined types (UDTs) and large objects (LOBs) User-defined functions (UDFs) Triggers Stored procedures When evaluating whether or not to use DB2 features, the following considerations need to be considered: Application independence Performance Application requirements SYS-ED/COMPUTER EDUCATION TECHNIQUES, INC. (DB2JDBC - 3.4) Ch 1: Page 12
  15. 15. DB2 UDB Prg in JAVA with JDBC Introduction 1.13 DB2 Stored Procedures Typically, applications access the database across the network. This can result in poor performance if a lot of data is being returned. A stored procedure runs on the database server. A client application can call the stored procedure which then performs the database access without returning unnecessary data across the network. Only the results the client application needs are returned by the stored procedure. Several benefits are gained by using stored procedures: Reduced network traffic. Access to features that exist only on the server. Enforcement of business rules. When an application calls the stored procedure, it will process data in a consistent way according to the rules defined in the stored procedure. If the rules need to be changed, the change only has to be made once in the stored procedure, not in every application that calls the stored procedure. SYS-ED/COMPUTER EDUCATION TECHNIQUES, INC. (DB2JDBC - 3.4) Ch 1: Page 13
  16. 16. DB2 UDB Prg in JAVA with JDBC Introduction 1.14 DB2 User-Defined Functions and Methods DB2 supports user-defined functions (UDFs) and methods. Code can be written in Visual Basic, C/C++, Java, or SQL to perform operations within any SQL statement that returns a single scalar value or a table. UDFs and methods provide significant flexibility. They return a single scalar value as part of an expression. Functions can return whole tables from non-database sources such as spreadsheets. UDFs and methods provide a way to standardize applications. By implementing a common set of routines, many applications can process data in the same way, thus ensuring consistent results. User-defined functions and methods also support object-oriented programming in applications. They provide for abstraction, allowing you to define the common interfaces that can be used to perform operations on data objects. And they provide for encapsulation, allowing access control to the underlying data of an object, protecting it from direct manipulation and possible corruption. SYS-ED/COMPUTER EDUCATION TECHNIQUES, INC. (DB2JDBC - 3.4) Ch 1: Page 14

×