Java Database Connectivity

Slides:



Advertisements
Similar presentations
Connecting to Databases. connecting to DB DB server typically a standalone application Server runs on localhost for smaller sites –i.e. Same machine as.
Advertisements

Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
Copyright  Oracle Corporation, All rights reserved. 2 Java and Databases: An Overview.
Java Database Connectivity (JDBC). 2/24 JDBC (Java DataBase Connectivity) - provides access to relational database systems JDBC is a vendor independent.
Distributed Application Development B. Ramamurthy.
1 C. Shahabi Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California
JDBC. In This Class We Will Cover: What SQL is What ODBC is What JDBC is JDBC basics Introduction to advanced JDBC topics.
1 Design patterns Lecture 4. 2 Three Important skills Understanding OO methodology Mastering Java language constructs Recognizing common problems and.
1 Foundations of Software Design Lecture 27: Java Database Programming Marti Hearst Fall 2002.
JDBC Java API for Database Connectivity. Layout of this recitation Introduction to JDBC API JDBC Architecture Understanding the design of JDBC API –Classes.
JDBC / ODBC JDBC is the java API that facilitate interaction of a java application with the DBMS. FIRST APPROACH:
Dale Roberts 8/24/ Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
Getting connected.  Java application calls the JDBC library.  JDBC loads a driver which talks to the database.  We can change database engines without.
1 CSC 440 Database Management Systems JDBC This presentation uses slides and lecture notes available from
Java Database Connectivity (JDBC) Francisco Pajaro Saul Acosta Nahum Quezada Manuel Rubio.
1 Java Database Connection (JDBC) There are many industrial-strength DBMS's commercially available in the market. Oracle, DB2, and Sybase are just a few.
© Wang Bin 2004 JDBC ----Java Database Connectivity.
CSE470 Software Engineering Fall Database Access through Java.
Intro to JDBC To effectively use Java Data Base Connectivity we must understand: 1.Relational Database Management Systems (RDBMS) 2.JDBC Drivers 3.SQL.
Java Database Connectivity (JDBC) Introduction to JDBC JDBC is a simple API for connecting from Java applications to multiple databases. Lets you smoothly.
Java Database Connectivity ASE. Java Database Connectivity (JDBC) l JDBC – provides an interface to Relational Data Sources l JDBC library provides the.
Database Programming in Java Corresponds with Chapter 32, 33.
Java Utility Classes CS 21b. Some Java Utility Classes Vector Hashtable StringTokenizer * import java.util.*;
Dr R R DOCSIT, Dr BAMU. Basic Java : Introduction to JDBC 2 Objectives of This Session State what is Java Database Connectivity State different.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui COMP 302 Database Systems Java Data Base Connectivity Lecturer Dr Pavle Mogin.
Designing and Developing WS B. Ramamurthy. Plans We will examine the resources available for development of JAX-WS based web services. We need an IDE,
JDBC. JDBC stands for Java Data Base Connectivity. JDBC is different from ODBC in that – JDBC is written in Java (hence is platform independent, object.
JDBC  The JDBC (Java Database Connectivity) API helps a Java program to access a database in a standard way  JDBC is a specification that tells the.
MIS 3023 Business Programming II Professor: Akhilesh Bajaj Introduction to JDBC © Akhilesh Bajaj, All Rights Reserved.
JDBC. Preliminaries Database Database Collection of data Collection of data DBMS DBMS Database management system Database management system Stores and.
JDBC Enterprise Systems Programming. JDBC  Java Database Connectivity  Database Access Interface provides access to a relational database (by allowing.
Accessing Database using JDBC. JDBC Objectives Gain basic knowledge of Java JDBC Become familiar with the basics of interacting with a database using.
COMP201 Java Programming Topic 15: Database Connectivity JDBC Reading: Chapter 4, Volume 2.
WEB/DB1 DATABASE PROGRAMMING 3JDBC by the ASU Scholars.
Java Database Connectivity (JDBC). Topics 1. The Vendor Variation Problem 2. SQL and Versions of JDBC 3. Creating an ODBC Data Source 4. Simple Database.
JDBC. Java.sql.package The java.sql package contains various interfaces and classes used by the JDBC API. This collection of interfaces and classes enable.
JDBC CS 124. JDBC Java Database Connectivity Database Access Interface provides access to a relational database (by allowing SQL statements to be sent.
12/6/2015B.Ramamurthy1 Java Database Connectivity B.Ramamurthy.
Li Tak Sing COMPS311F. Database programming JDBC (Java Database Connectivity) Java version of ODBC (Open Database Connectivity) ODBC provides a standard.
JDBC
Java and Databases. JDBC Architecture Java Application JDBC API Data Base Drivers AccessSQL Server DB2InformixMySQLSybase.
UNIT III - JDBC JDBC Overview – JDBC implementation – Connection class – Statements - Catching Database Results, handling database Queries. Networking–
DATABASE CONNECTIVITY TO MYSQL. Introduction =>A real life application needs to manipulate data stored in a Database. =>A database is a collection of.
CSI 3125, Preliminaries, page 1 JDBC. CSI 3125, Preliminaries, page 2 JDBC JDBC stands for Java Database Connectivity, which is a standard Java API (application.
Access Databases from Java Programs via JDBC Tessema M. Mengistu Department of Computer Science Southern Illinois University Carbondale
Basics of JDBC Session 14.
CS122B: Projects in Databases and Web Applications Winter 2016
Advanced Java Session 5 New York University School of Continuing and Professional Studies.
Introduction to JDBC Instructor: Mohamed Eltabakh 1.
In the Name Of Almighty Allah. Java Application Connection To Mysql Created by Hasibullah (Sahibzada) Kabul Computer Science Faculty Afghanistan.
6-1 JAVA DATABASE CONNECTOR Colorado Technical University IT420 Tim Peterson.
Java and database. 3 Relational Databases A relational Database consists of a set of simple rectangular tables or relations The column headings are.
Database: JDBC Overview
DEPTT. OF COMP. SC & APPLICATIONS
Interacting with Database
Lec - 14.
Accessing the Database Server: ODBC, OLE DB, and ADO
JDBC Database Management Database connectivity
Database JDBC Overview CS Programming Languages for Web Applications
Advanced Web Automation Using Selenium
JDBC.
Introduction to Programming with Java
Mr. Harish Sharma Asst. Professor Dept. of CA & IT SGRRITS Dehradun
Interacting with Database
JDBC – ODBC DRIVERS.
MSIS 655 Advanced Business Applications Programming
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
Java API for Database Connectivity
Database Processing: David M. Kroenke’s Chapter Twelve: Part One
Presentation transcript:

Java Database Connectivity B.Ramamurthy 1/17/2019 B.Ramamurthy

Introduction Most popular form of database system is the relational database system. Examples: MS Access, Sybase, Oracle, MS Sequel Server. Structured Query Language (SQL) is used among relational databases to construct queries. These queries can be stand-alone or embedded within applications. This form of SQL is known as embedded SQL. 1/17/2019 B.Ramamurthy

Simple Database Application DBMS DB Ex: Access Oracle Sybase 1/17/2019 B.Ramamurthy

Multi-Databases A P L I C T O N DBMS 1 DB DBMS 2 DB DBMS 3 DB 1/17/2019 B.Ramamurthy

Standard Access to DB A P L I C T O N D R V E M G DBMS Driver 1 1/17/2019 B.Ramamurthy

ODBC Architecture Application Class1 Class2 ODBC Driver Manager DriverType1 DriverType2 DriverType3 DataSource3 DataSource2 DataSource1 1/17/2019 B.Ramamurthy

Open Database Connectivity (ODBC) Standard ODBC standard is an interface by which application programs can access and process SQL databases in a DBMS-independent manner. It contains: A Data Source that is the database, its associated DBMS, operating system and network platform A DBMS Driver that is supplied by the DBMS vendor or independent software companies A Driver Manager that is supplied by the vendor of the O/S platform where the application is running 1/17/2019 B.Ramamurthy 4

ODBC Interface It is a system independent interface to database environment that requires an ODBC driver to be provided for each database system from which you want to manipulate data. The database driver bridges the differences between your underlying system calls and the ODBC interface functionality. 1/17/2019 B.Ramamurthy

An Example odbc standard API Application DriverManager Sybase driver mSQL driver Informix driver 1/17/2019 B.Ramamurthy

Application in Java jdbc API odbc standard API Application in Java DriverManager Sybase driver mSQL driver Informix driver 1/17/2019 B.Ramamurthy

Java Support for ODBC : JDBC When applications written in Java want to access data sources, they use classes and associated methods provided by Java DBC (JDBC) API. JDBC is specified an an “interface”. An interface in Java can have many “implementations”. So it provides a convenient way to realize many “drivers” 1/17/2019 B.Ramamurthy

Java Support for SQL Java supports embedded SQL. Also it provides an JDBC API as a standard way to connect to common relational databases. You need a JDBC:ODBC bridge for using the embedded SQL in Java. Java.sql package and an extensive exception hierarchy. We will examine incorporating this bridge using sample code. 1/17/2019 B.Ramamurthy

Data Source Local relational database; Ex: Oracle Remote relational database on a server; Ex: SQLserver On-line information service; Ex: Dow Jones, Customer database 1/17/2019 B.Ramamurthy

Data Source and Driver Data source is the data base created using any of the common database applications available. Your system should have the driver for the database you will be using. For example your Windows system should have the MS Access Driver. There are a number of JDBC drivers available. Information on installing them is available at : http://industry.java.sun.com/products/jdbc/drivers 1/17/2019 B.Ramamurthy

JDBC Components Driver Manager: Loads database drivers, and manages the connection between application & driver. Driver: Translates API calls to operations for a specific data source. Connection: A session between an application and a driver. Statement: A SQL statement to perform a query or an update operation. Metadata: Information about the returned data, driver and the database. Result Set : Logical set of columns and rows returned by executing a statement. 1/17/2019 B.Ramamurthy

JDBC Classes Java supports DB facilities by providing classes and interfaces for its components DriverManager class Connection interface (abstract class) Statement interface (to be instantiated with values from the actual SQL statement) ResultSet interface 1/17/2019 B.Ramamurthy

Driver Manager Class Provides static, “factory” methods for creating objects implementing the connection interface. Factory methods create objects on demand when a connection is needed to a DB driver, DriverManager does it using it factory methods. 1/17/2019 B.Ramamurthy

Connection interface Connection class represents a session with a specific data source. Connection object establishes connection to a data source, allocates statement objects, which define and execute SQL statements. Connection can also get info (metadata) about the data source. 1/17/2019 B.Ramamurthy

Statement interface Statement interface is implemented by the connection object. Statement object provides the workspace for SQL query, executing it, and retrieving returned data. SELECT {what} FROM {table name} WHERE {criteria} ORDER BY {field} Queries are embedded as strings in a Statement object. Types: Statement, PreparedStatement, CallableStatement 1/17/2019 B.Ramamurthy

ResultSet interface Results are returned in the form of an object implementing the ResultSet interface. You may extract individual columns, rows or cell from the ResultSet using the metadata. 1/17/2019 B.Ramamurthy

JDBC Application Architecture Result Set Connection Statement Driver Manager Driver Driver Driver DataSource DataSource DataSource 1/17/2019 B.Ramamurthy

JDBC Programming Steps Import necessary packages; Ex: import java.sql.*; Load JDBC driver(driver should have been installed) Data source and its location should have been registered. Allocate Connection object, Statement object and ResultSet object Execute query using Statement object Retrieve data from ResultSet object Close Connection object. 1/17/2019 B.Ramamurthy

Identifying Data Sources It is specified using URL format. <scheme>: <sub_scheme>:<scheme-specific-part> Example(for local source): jdbc:odbc:tech_books Alternatively, for remote connection, jdbc:odbc://bina.cse.buffalo.edu:4333/tech_books 1/17/2019 B.Ramamurthy

Summary JDBC API of Java language conforms to the ODBC standard. It supports ODBC by providing classes/interfaces for driver manager, driver, connection, statement and resultset and others. You can access various components in JDBC by instantiating or implementing objects and accessing their methods. Go through the tutorial at: http://developer.java.sun.com/developer/onlineTraining/Database/JDBC20Intro/ 1/17/2019 B.Ramamurthy