The J2EE Platform,JDBC(Java Database Connectivity)

Total Page:16

File Type:pdf, Size:1020Kb

The J2EE Platform,JDBC(Java Database Connectivity) Sub : J2EE Chapter – 1 The J2EE platform B.C.A. Sem -5 1 The J2EE Platform,JDBC(Java Database Connectivity) Topics Covered 1. Introduction to J2EE 2. Enterprise Architecture Style. 3. Enterprise Architecture 4. J2EE Platform. 5. J2EE API’s. 6. Introduction to J2EE APIs 7. introduction to container 8. Tomcat as a web container 9. Introduction. 10. JDBC Architecture 11. Datatypes in JDBC 12. Processing Queries 13. Database exception handling 14. Database Driver 15. JDBC API for connectivity 16. Connection 17. Driver Manager class 18. Statement 19. Prepared Statement 20. Callable Statement 21. ResultSet 22. Other JDBC API 23. Database Meta Data 24. Result set Meta Data 25. Connecting with Databses(MySQL,Oracle,Access) Page 1 of 24 Sub : J2EE Chapter – 1 The J2EE platform B.C.A. Sem -5 Introduction to J2EE Core java application only provides facility to work with windows based applications. If we required developing the enterprise level application, it will not work. Advance java programming provides the facility to develop the Enterprise based and Internet based Application. The J2EE is an open source. It reduces the cost of developing multi-tier applications. It provides a number of APIs to develop the different types of applications, such as JDBC(Java Database Connectivity) used for making connection between the java programs and database, JSP and servlets to create the dynamic web page, RMI(Remote Method Invocation) to create the remote objects. J2EE platforms also include concept of containers to provide the interface between the clients, server and the database. J2EE provides many framework such as JSF, spring, structs, hibernate to develop very attractive, secure, user-friendly, database driven enterprise application. 1. Introduction The Tier A tier is an abstract concept that defines a group of technologies that provides one or more services to its clients. In simplest words, tier is collection of similar technologies in a group. Introduction to Enterprise Application Design Framework Enterprise Application is divided in to following six (6) logical layers which are related to the client tier, middle tier, and database tier. It defines which layer belongs to which tier. Presentation Manager . It defines User interface . It is located on the client tier. Manages the information displayed to the user. Presentation Logic . Defines the Navigation system of the user interface . Focused on how and what will be displayed to the user. It may locate with the client tier or business tier or the database tier, based on thin client and thick client. Application Logic . Defines the actual application logic with it. It may be, connectivity with the database, validation over the various inputs etc. It may locate with the client tier or business tier or the database tier, based on thin client and thick client. Business Logic . Contains business rules of applications. Should be shared with whole application. Page 2 of 24 Sub : J2EE Chapter – 1 The J2EE platform B.C.A. Sem -5 . It may located with business tier or the database tier, based on thin client and thick client. Database Logic . Defines the table structure and relation among the tables of database . Includes various constraints of the table. Located with the database tier. Database Manager . Stores the persistent (constant) data. Always located with the database tier. Enterprise Architecture Style Single tier Architecture When User inputs, its verifications, business logic, and data access all these are combined together in a single computer such kind of architecture is known as Single tier architecture. In this all layers are located on a single machne. Advantages . Easy to manage . Data consistency is simple due to data stored at single location. Disadvantages . Single storage is not sufficient due to large number of data . Sharing of data in large amount is not possible. Multiple user can’t be handled Two tier Architecture Two tier architecture is divided into two separate tiers, client machine and database server machine (server). The application includes the presentation and business logic. Data accessed by connecting client machine to a database which is lying on another machine (i.e. server) In this architecture there are various types of clients which are discussed below. Advantages . Any changes made in data access logic will not affect the presentation and the business logic . Using this type of architecture it is easy to develop an application. Page 3 of 24 Sub : J2EE Chapter – 1 The J2EE platform B.C.A. Sem -5 Disadvantages . Only supports limited number of users. Because each client requires its own connections and each connection requires CPU and memory. So, when number of connection increases the database performance decreases. Thin Client . In two tier architecture, presentation manager resides only with the client tier then such client is called Thin client, while other presentation logic, application logic, business logic, data logic and database manager reside with the server side. Thick Client . In two tier architecture, presentation manager, presentation logic and application logic are resides in client tier then such architecture is called thick client. Other like business logic, data logic and database manager resides with the server side Page 4 of 24 Sub : J2EE Chapter – 1 The J2EE platform B.C.A. Sem -5 Normal Client . In two tier architecture, if the presentation manager and presentation logic resides in the client tier then the client is called Normal Client. Other like application logic, business logic, data logic and database manager resides with the server side. Three tier Architecture Applications which are divided into three tiers client tier, middle tier (business tier) and database tier is known as three tier architecture application. Logic is physically divided into separate tier. The presentation layer and logic runs on the client machine. Application and business logic runs on J2EE server and database logic is there with database layer. Thin Client Page 5 of 24 Sub : J2EE Chapter – 1 The J2EE platform B.C.A. Sem -5 . In three tier architecture if the presentation manager is resides only with the client tier then client is called as thin client. Presentation logic, application logic and business logic are with the business tier . Database logic and database manager are with the database tier (EIS – Enterprise Information System.) Thick Client . In three tier architecture if the presentation manager ,presentation logic, application logic resides with the client tier then client is called as thick client. Business logic only with the business tier . Database logic and database manager are with the database tier (EIS – Enterprise Information System.) Advantages . Improves scalability since application server are deployed on many machines. Database connection not required longer from each and every client, only requires connections from a smaller number of application server. Better reusability due to same logic can be initiated from many clients. Security is ensured because not direct access to the database. Disadvantages . Increases complexity N-tier architecture Application divided into more than three tier can be called as N-tier architecture. In N-tier architecture it is not decided how many tier can be present. Number of tiers in application is depends on the computing and network hardware on which application is to be deployed. Basically divided into client tier, web tier, business (EJB) tier and database tier (EIS). Client tier . Collection of user interface for user request and the print the response . Runs on the client machine. Uses browser or applet as client side application. Web tier . Collection of JSP and servlet dynamic webpages to handle the HTTP specific request logons, session , accesses the business services and response back to the client. Business tier . Collection of business logic for J2EE application. For example EJB (Enterprise JavaBeans) . Using such business tier, same business logic can support different types of client like browser, WAP, other stand-alone application. Database (EIS) tier . EIS tier consist of the DBMS/RDBMS. Page 6 of 24 Sub : J2EE Chapter – 1 The J2EE platform B.C.A. Sem -5 . Handles User SQL requests and generates appropriate response based on the queries. Stores all persistent data in database Advantages . Separation of User interface logic, business logic is done . Business logic resides on small number of centralized machines. Easy to maintain, to manage, to scale, loosely coupled etc., Modification is easy Disadvantages . More complex structure . Difficult to setup and maintain all separated layers Enterprise Architecture Java 2 Enterprise edition is basically developed for commercial project and web- solution. Business solution for commercial project solved using multi-tier architecture. The J2EE platform use multi-tier distributed application model for enterprise application. By dividing application logic into various component according to its tasks or functions and various application components that are gathered J2EE application are installed on different machine depending on the tier. Page 7 of 24 Sub : J2EE Chapter – 1 The J2EE platform B.C.A. Sem -5 Following tiers are available for J2EE. Client tier (Client machine) . Web tier (J2EE server) . Business tier ( J2EE server) . EIS tier (database server) J2EE Platform Introduction to editions of Java. J2SE – Java 2 standard edition normally used for developing desktop application.
Recommended publications
  • Filemaker 16 ODBC and JDBC Guide
    FileMaker®16 ODBC and JDBC Guide © 2004–2017 FileMaker, Inc. All Rights Reserved. FileMaker, Inc. 5201 Patrick Henry Drive Santa Clara, California 95054 FileMaker, FileMaker Go, and the file folder logo are trademarks of FileMaker, Inc. registered in the U.S. and other countries. FileMaker WebDirect and FileMaker Cloud are trademarks of FileMaker, Inc. All other trademarks are the property of their respective owners. FileMaker documentation is copyrighted. You are not authorized to make additional copies or distribute this documentation without written permission from FileMaker. You may use this documentation solely with a valid licensed copy of FileMaker software. All persons, companies, email addresses, and URLs listed in the examples are purely fictitious and any resemblance to existing persons, companies, email addresses, or URLs is purely coincidental. Credits are listed in the Acknowledgments documents provided with this software. Mention of third-party products and URLs is for informational purposes only and constitutes neither an endorsement nor a recommendation. FileMaker, Inc. assumes no responsibility with regard to the performance of these products. For more information, visit our website at http://www.filemaker.com. Edition: 01 Contents Chapter 1 Introduction 5 About this guide 5 Where to find FileMaker documentation 5 About ODBC and JDBC 6 Using FileMaker software as an ODBC client application 6 Importing ODBC data 6 Adding ODBC tables to the relationships graph 6 Using a FileMaker database as a data source 7 Accessing a
    [Show full text]
  • Chapter 3 DB Gateways.Pptx
    Prof. Dr.-Ing. Stefan Deßloch AG Heterogene Informationssysteme Geb. 36, Raum 329 Tel. 0631/205 3275 [email protected] Chapter 3 DB-Gateways Outline n Coupling DBMS and programming languages n approaches n requirements n Programming Model (JDBC) n overview n DB connection model n transactions n Data Access in Distributed Information System Middleware n DB-Gateways n architectures n ODBC n JDBC n SQL/OLB – embedded SQL in Java n Summary 2 © Prof.Dr.-Ing. Stefan Deßloch Middleware for Information Systems Coupling Approaches – Overview n Static Embedded SQL n static SQL queries are embedded in the programming language n cursors to bridge so-called impedance mismatch n preprocessor converts SQL into function calls of the programming language n potential performance advantages (early query compilation) n vendor-specific precompiler and target interface n resulting code is not portable n Dynamic Embedded SQL n SQL queries can be created dynamically by the program n character strings interpreted as SQL statements by an SQL system n preprocessor is still required n only late query compilation n same drawbacks regarding portability as for static embedded n Call-Level Interface (CLI) n standard library of functions that can be linked to the program n same capabilities as (static and dynamic) embedded n SQL queries are string parameters of function invocation n avoids vendor-specific precompiler, allows to write/produce binary-portable programs 3 © Prof.Dr.-Ing. Stefan Deßloch Middleware for Information Systems Coupling Approaches (Examples)
    [Show full text]
  • Preview JDBC Tutorial
    About the Tutorial JDBC API is a Java API that can access any kind of tabular data, especially data stored in a Relational Database. JDBC works with Java on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX. Audience This tutorial is designed for Java programmers who would like to understand the JDBC framework in detail along with its architecture and actual usage. Prerequisites Before proceeding with this tutorial, you should have a good understanding of Java programming language. As you are going to deal with RDBMS, you should have prior exposure to SQL and Database concepts. Copyright & Disclaimer Copyright 2015 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or in this tutorial, please notify us at [email protected] i Table of Contents About the Tutorial ....................................................................................................................................
    [Show full text]
  • Java Database Connectivity (JDBC)
    MODULE - V Java Database Connectivity (JDBC) MODULE 5 Java Database Connectivity (JDBC) Module Description Java Database Connectivity (JDBC) is an Application Programming Interface (API) used to connect Java application with Database. JDBC is used to interact with the various type of Database such as Oracle, MS Access, My SQL and SQL Server and it can be stated as the platform-independent interface between a relational database and Java programming. This JDBC chapter is designed for Java programmers who would like to understand the JDBC framework in detail along with its architecture and actual usage. iNurture’s Programming in Java course is designed to serve as a stepping stone for you to build a career in Information Technology. Chapter 5.1 Introduction to JDBC Chapter 5.2 Setting up a Java Database Connectivity Chapter Table of Contents Chapter 5.1 Introduction to JDBC Aim ..................................................................................................................................................... 255 Instructional Objectives ................................................................................................................... 255 Learning Outcomes .......................................................................................................................... 255 5.1.1 Database Connectivity ............................................................................................................ 256 Self-assessment Questions .....................................................................................................
    [Show full text]
  • Java Database Connectivity (JDBC) J2EE Application Model
    Java DataBase Connectivity (JDBC) J2EE application model J2EE is a multitiered distributed application model client machines the J2EE server machine the database or legacy machines at the back end JDBC API JDBC is an interface which allows Java code to execute SQL statements inside relational databases Java JDBC driver program connectivity for Oracle data processing utilities driver for MySQL jdbc-odbc ODBC bridge driver The JDBC-ODBC Bridge ODBC (Open Database Connectivity) is a Microsoft standard from the mid 1990’s. It is an API that allows C/C++ programs to execute SQL inside databases ODBC is supported by many products. The JDBC-ODBC Bridge (Contd.) The JDBC-ODBC bridge allows Java code to use the C/C++ interface of ODBC it means that JDBC can access many different database products The layers of translation (Java --> C --> SQL) can slow down execution. The JDBC-ODBC Bridge (Contd.) The JDBC-ODBC bridge comes free with the J2SE: called sun.jdbc.odbc.JdbcOdbcDriver The ODBC driver for Microsoft Access comes with MS Office so it is easy to connect Java and Access JDBC Pseudo Code All JDBC programs do the following: Step 1) load the JDBC driver Step 2) Specify the name and location of the database being used Step 3) Connect to the database with a Connection object Step 4) Execute a SQL query using a Statement object Step 5) Get the results in a ResultSet object Step 6) Finish by closing the ResultSet, Statement and Connection objects JDBC API in J2SE Set up a database server (Oracle , MySQL, pointbase) Get a JDBC driver
    [Show full text]
  • Database Management Systems Ebooks for All Edition (
    Database Management Systems eBooks For All Edition (www.ebooks-for-all.com) PDF generated using the open source mwlib toolkit. See http://code.pediapress.com/ for more information. PDF generated at: Sun, 20 Oct 2013 01:48:50 UTC Contents Articles Database 1 Database model 16 Database normalization 23 Database storage structures 31 Distributed database 33 Federated database system 36 Referential integrity 40 Relational algebra 41 Relational calculus 53 Relational database 53 Relational database management system 57 Relational model 59 Object-relational database 69 Transaction processing 72 Concepts 76 ACID 76 Create, read, update and delete 79 Null (SQL) 80 Candidate key 96 Foreign key 98 Unique key 102 Superkey 105 Surrogate key 107 Armstrong's axioms 111 Objects 113 Relation (database) 113 Table (database) 115 Column (database) 116 Row (database) 117 View (SQL) 118 Database transaction 120 Transaction log 123 Database trigger 124 Database index 130 Stored procedure 135 Cursor (databases) 138 Partition (database) 143 Components 145 Concurrency control 145 Data dictionary 152 Java Database Connectivity 154 XQuery API for Java 157 ODBC 163 Query language 169 Query optimization 170 Query plan 173 Functions 175 Database administration and automation 175 Replication (computing) 177 Database Products 183 Comparison of object database management systems 183 Comparison of object-relational database management systems 185 List of relational database management systems 187 Comparison of relational database management systems 190 Document-oriented database 213 Graph database 217 NoSQL 226 NewSQL 232 References Article Sources and Contributors 234 Image Sources, Licenses and Contributors 240 Article Licenses License 241 Database 1 Database A database is an organized collection of data.
    [Show full text]
  • Oracle Database JDBC Developer's Guide and Reference
    Oracle® Database JDBC Developer’s Guide 11g Release 2 (11.2) E16548-03 September 2011 This book describes how to use Oracle JDBC drivers to develop powerful Java database applications. Oracle Database JDBC Developer's Guide, 11g Release 2 (11.2) E16548-03 Copyright © 1999, 2011, Oracle and/or its affiliates. All rights reserved. Primary Author: Tulika Das, Venkatasubramaniam Iyer, Elizabeth Hanes Perry, Brian Wright, Thomas Pfaeffle Contributing Author: Brian Martin Contributor: Kuassi Mensah, Douglas Surber, Paul Lo, Ed Shirk, Tong Zhou, Jean de Lavarene, Rajkumar Irudayaraj, Ashok Shivarudraiah, Angela Barone, Rosie Chen, Sunil Kunisetty, Joyce Yang, Mehul Bastawala, Luxi Chidambaran, Srinath Krishnaswamy, Longxing Deng, Magdi Morsi, Ron Peterson, Ekkehard Rohwedder, Catherine Wong, Scott Urman, Jerry Schwarz, Steve Ding, Soulaiman Htite, Anthony Lai, Prabha Krishna, Ellen Siegal, Susan Kraft, Sheryl Maring This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S.
    [Show full text]
  • Database Access Database Programming Using JDBC
    Database Access Database Programming using JDBC: JDBC is an international standard for programming access to SQL databases. It was developed by JavaSoft, a subsidiary of Sun Microsystems. Relational Database Management System supports SQL. As we know that Java is platform independent, JDBC makes it possible to write a single database application that can run on different platforms and interact with different Database Management Systems. Java Database Connectivity is similar to Open Database Connectivity (ODBC) which is used for accessing and managing database, but the difference is that JDBC is designed specifically for Java programs, whereas ODBC is not dependent upon any language. JDBC Driver Model JDBC supports two-tier and three-tier model: I. Two-tier Model In this model the Java applets and application are directly connected with any type of database. The client directly communicates with database server through JDBC driver. As another layer, the Manager should communicate with various third party drivers that actually connect to the database and return information from the query or perform action specified by the query. II. Three-tier Model In this model, client connects with database server through a middle-tier server, which is used for various purposes. Middle-tier server performs various functions. It extracts the SQL command from the client and sends these commands to the database server. Also, it extracts the result from the database server and submits the same to the client. Exploring JDBC Architecture JDBC is open specification given by Sun Microsystems having rules and guidelines to develop JDBC driver. JDBC driver is a bridge software between Java application and database software.
    [Show full text]
  • Integration of Spatial Vector Data in Enterprise Relational Database Environments
    Integration of Spatial Vector Data in Enterprise Relational Database Environments Dissertation zur Erlangung des akademischen Grades Doktor-Ingenieur (Dr.-Ing.) vorgelegt dem Rat der Fakult¨at f¨ur Mathematik und Informatik der Friedrich-Schiller-Universit¨at Jena im Juli 2006 von Dipl.-Inf. Knut Stolze geboren am 8. Januar 1975 in Jena, Th¨uringen Gutachter: 1. Prof. Dr. Klaus K¨uspert, Friedrich-Schiller-University Jena 2. Prof. Johann-Christoph Freytag, Ph.D., Humboldt-Universit¨at zu Berlin 3. Dr. Albert Maier, IBM Deutschland Entwicklung GmbH, B¨oblingen Tag der letzten Pr¨ufung des Rigorosums: 7. November 2006 Tag der ¨offentlichen Verteidigung: 10. November 2006 ii To My Wife Annett iv Abstract Spatial and geometric data can be found in virtually every relational database. Such data is often not explicitly modeled but rather hidden in addresses, for example. Unless spatial data is treated as first class citizen in the relational database management systems (RDBMSs), spatial features cannot be leveraged and exploited by applications to their full extent. Several products provide the capabilities to store and query geometric data directly in relational databases. Those products include dedicated data types along with associated spatial functions and indexing mechanisms. The SQL/MM spatial standard exists to ensure that the spatial interface provided by products are compatible. The standard covers basic spatial functionality only. Data types are defined and include a set of routines that are used to construct spatial values from external data formats, compare two geometries regarding their spatial relationship, generate new geometries, or to extract spatial properties. However, more advanced func- tionality is crucial for applications and their business logic is still lacking.
    [Show full text]
  • J2EE-Praktikum JDBC
    J2EE-Praktikum JDBC Peter Thiemann Universität Freiburg J2EE-Praktikum, WS2005/2006 Inhalt 1 Einführung JDBC Features Four Types of Drivers Choosing a Driver 2 Verwendung Portability Was ist JDBC? JDBC = Java DataBase Connectivity Java API for access to SQL databases (SQL = Structured Query Language) Inspired by ODBC (Open DataBase Connectivity) Accesses database through JDBC drivers JDBC methods transmit SQL commands as strings to a database "select name, lastname, salary from personnel where lastname = ’Smith’" Database performs SQL commands and delivers the requested data and success or failure messages JDBC methods read data delivered from the database JDBC Features Query, insert, and update database content Support for transactions cursors prepared statements and stored procedures metadata (e.g., column names) JDBC Application Application JDBC DBMS Four Types of Drivers Application JDBC JDBC−ODBC Bridge Native Library JDBC Net Driver Native Protocol ODBC DB Library DB Library Middleware DBMS Type 1 Drivers Application JDBC Type 1 drivers implement the JDBC API as a mapping to another data access API, JDBC−ODBC Bridge such as ODBC. Drivers of this type are generally dependent on a native library, ODBC which limits their portability. The JDBC- ODBC Bridge driver is an example of a Type 1 driver. From JDBC API Specification DB Library JDBC-ODBC Bridge DBMS Properties of Type 1 Drivers Advantages The same Type 1 JDBC driver can communicate with every database system for which an ODBC driver is available. Very simple driver. Disadvantages Platform dependent (Microsoft) ODBC must be installed DB must support ODBC driver Use discouraged if pure Java driver available Type 2 Drivers Application JDBC Type 2 drivers are written partly in the Ja- va programming language and partly in Native Library native code.
    [Show full text]
  • Java Database Programming with JDBC:Introduction
    Java Database Programming with JDBC by Pratik Patel Coriolis, The Coriolis Group ISBN: 1576100561 Pub Date: 10/01/96 Table of Contents Introduction Welcome to the future of database connectivity. The Java Database Connectivity ( JDBC ) specification is a new basis for developers to interface with data sources. The structure of the JDBC is designed to allow developers to program for a standard interface, and let the low-level JDBC driver for different databases deal with the connection and querying of the databases; hence, the developer does not need to worry about dealing with different SQL flavors for each database. The JDBC is also very flexible—a developer doesn’t necessarily lose features specific to the target database. Best of all, the JDBC is based on the Java language! Getting Software The software that you’ll need to get started with the JDBC is readily available on the Web. The JDBC drivers that you will need to connect to your databases are currently available for most popular databases from a variety of software vendors. The basic package you’ll need is the JDBC API, which consists of the core classes of the JDBC. If you don’t already have a Java development kit, such as Javasoft’s JDK, you’ll need that as well. At the time this manuscript was finished, the examples in the book were tested with the JavaSoft JDK, Symantec Cafe, Microsoft J++, and Borland’s C+ + 5.0 with Java support. You can get the JavaSoft JDK at http://www.javasoft.com. The JDBC API, and the ODBC driver for JDBC (that’s right, you can use the JDBC with your current ODBC drivers!) commonly referred to as the JDBC-ODBC bridge can be downloaded at the JDBC Web site at http://splash.javasoft.com/ jdbc.
    [Show full text]
  • Java Database Connectivity (JDBC)
    JDBC Dr. Jim Arlow Clear View Training Limited www.clearviewtraining.com © Clear View Training 2005 v1.3 1 Copyright notice This course is Copyright © 2000 Clear View Training Limited. All rights reserved. Materials in this course may not be reproduced electronically or optically without express permission from the copyright holder. For reprint permissions, contact [email protected] © Clear View Training 2005 v1.3 2 What is JDBC JDBC, often known as Java Database Connectivity, Java Application or Applet provides a Java API for updating and querying JDBC relational databases using Structured Query Language (SQL) JDBC is now at version 2.0, although many databases RDBMS don’t as yet support all of the JDBC 2.0 features! © Clear View Training 2005 v1.3 3 The 4 step approach to JDBC Every JDBC program is made up of the following 4 steps: Open a connection to the DB We’ll look at each of the Execute a SQL statement four steps in detail! Process the result Close the connection to the DB © Clear View Training 2005 v1.3 4 Example JDBC program 1. open connection to DB 1 import java.sql.*; 2 class SelectProducts 2. execute SQL statement 3 { 3. process result 4 public static void main(java.lang.String[ ] args) 5 { 4. close connection to DB 6 try 7 { 8 Class.forName( "COM.ibm.db2.jdbc.app.DB2Driver" ); 9 Connection con = DriverManager.getConnection( "jdbc:db2:TEST", "db2admin", " db2admin " ); 1 10 Statement statement = con.createStatement( ); 11 ResultSet rs = statement.executeQuery("SELECT NAME, PRICE FROM PRODUCT"); 2 12 while
    [Show full text]