JDBC Database Management Database connectivity

Slides:



Advertisements
Similar presentations
Java Database Connectivity (JDBC). 2/24 JDBC (Java DataBase Connectivity) - provides access to relational database systems JDBC is a vendor independent.
Advertisements

JDBC - Java Database Connectivity The objectives of this chapter are: To describe the architecture of JDBC To outline the classes in the java.sql package.
Distributed Application Development B. Ramamurthy.
1 C. Shahabi Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California
1 Lecture 29 More on JDBC Overview  Objectives of this lecture  JDBC and its Drivers  Connecting to Databases (Java’s Connection class)  Querying a.
CSE470 Software Engineering Fall Database Access through Java.
ODBC and JDBC What are they – libraries of function calls that support SQL statements Why do we need them –Provide a way for an application to communicate.
JDBC Java API for Database Connectivity. Layout of this recitation Introduction to JDBC API JDBC Architecture Understanding the design of JDBC API –Classes.
Objectives Describe JDBC Describe JDBC Driver Types
Java MS Access database connectivity Follow these steps: 1)Go to the start->Control Panel->Administrative Tools- > data sources. 2)Click Add button and.
ODBC Open DataBase Connectivity a standard database access method developed by Microsoft to access data from any application regardless of which database.
JDBC / ODBC JDBC is the java API that facilitate interaction of a java application with the DBMS. FIRST APPROACH:
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.
Java Database Connectivity (JDBC) Francisco Pajaro Saul Acosta Nahum Quezada Manuel Rubio.
Chapter 7 PHP Interacts with Ms. Access (Open DataBase Connectivity (ODBC))
Java Database Connectivity Vijayan Sugumaran Department of DIS Oakland University.
Jaeki Song JAVA Lecture 11 Java Database Connectivity.
JDBC. What is JDBC JDBC is an acronym for –Java Data Base Connectivity. It allows java/jsp program to connect to any database.
© Wang Bin 2004 JDBC ----Java Database Connectivity.
CSE470 Software Engineering Fall Database Access through Java.
Java Database Connectivity (JDBC) Introduction to JDBC JDBC is a simple API for connecting from Java applications to multiple databases. Lets you smoothly.
Database Programming in Java Corresponds with Chapter 32, 33.
CIS 270—Application Development II Chapter 25—Accessing Databases with JDBC.
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,
Connecting to Oracle using Java November 4, 2009 David Goldschmidt, Ph.D. David Goldschmidt, Ph.D.
JDBC Java and Databases, including Postgress. JDBC l Developed by Industry leaders l Three main goals: –JDBC should be an SQL-level API –JDBC should capitalize.
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.
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.
Copyright © 2002 ProsoftTraining. All rights reserved. Building Database Client Applications Using JDBC 2.0.
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.
Session 30 Basics of JDBC. Java Simplified / Session 30 / 2 of 33 Review A Swing menu consists of a menubar, menuitems and menus. Trees are used to depict.
JDBC CHAPTER-2. JDBC - Java Database Connectivity. JDBC from Sun Microsystems provides API or Protocol to interact with different databases. With the.
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.
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.
JDBC and SQLJ CIS 612 Spring JDBC JDBC is an API that enables database access from Java programs JDBC for DB access provides ◦ Portability across.
JDBC CS 260 Database Systems. Overview  Introduction  JDBC driver types  Eclipse project setup  Programming with JDBC  Prepared statements  SQL.
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.
ODBC : Open Database Connectivity SNU OOPSLA Lab. October 2005.
JDBC Chapter 1 JDBC Introduction
JDBC - Java Database Connectivity. JDBC provides Java applications with access to most database systems via SQL The architecture and API closely resemble.
Advanced Java Session 5 New York University School of Continuing and Professional Studies.
Ch. NoNameMarks 01AWT24 02Networking18 03JDBC20 04Swing18 05Servlet20 Advance Java Programming.
DEPTT. OF COMP. SC & APPLICATIONS
Note: To complete the examples in this section you need access to a database!! Most of the examples work for any database with JDBC drivers. However, connecting.
Interacting with Database
Lec - 14.
ODBC, OCCI and JDBC overview
W04 Connecting 3rd Party Application to ODBC
JDBC.
Introduction to Programming with Java
Chapter 16 JAVA DATABASE CONNECTIVITY
Objectives In this lesson, you will learn about:
Interacting with Database
JDBC – ODBC DRIVERS.
Java Database Connectivity
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
ODBC and JDBC.
Java API for Database Connectivity
Lecture 11 Database Connection
Presentation transcript:

JDBC Database Management Database connectivity Installing the ODBC driver Querying a database Adding, modifying and deleting records

Database Management A database is a collection of related information and a DBMS is a software that provides you with a mechanism to retrieve, modify and add to the database. There are many DBMS/RDBMS products available. eg- MS-Access, MS-SQL Server, Oracle, Sybase, Informix, Progress and Ingres.

Database Connectivity Any application to communicate with the database, it needs to have the following information: The RDBMS/DBMS product using which database is created. The location of the database. The name of the database. Here you could able to work with only one kind of database and difficult to code. The above problem is solved by Microsoft’s standard for communication using Open Database Connectivity(ODBC). Queries For Data Application MS-Access Responds to a Query MS-SQL

ODBC Application Programming Interface(API) ODBC API is a set of library routines that enables your program to access a variety of databases. All you need to install a DBMS- specific ODBC driver. MS-Access Application ODBC Driver Manager Access Driver SQL Driver MS-SQL ODBC Application Architecture

JDBC API JDBC API There are several categories of JDBC drivers available. JDBC-ODBC bridge+ODBC driver Native API partly Java driver. JDBC-Net pure Java driver Native protocol pure java driver. MS-Access Application JDBC Driver Manager JDBC- ODBC Bridge Driver Access Driver SQL Driver MS-SQL JDBC Application Architecture

JDBC provides a standard library for accessing relational databases -API standardizes Way to establish connection to database Approach to initiating queries Method to create stored (parameterized)queries The data structure of query result(table) Determine the number of columns Looking up metadata, etc., -API does not standardize SQL syntax JDBC is not embedded SQL -JDBC class located in java.sql package

JDBC consists of two parts : -JDBC API, a purely Java-based API -JDBC Driver Manager, which communicates with --Vendor-specific drivers that perform the real communication with the database. --Point : translation to vendor format is performed on the client -No changes needed to server -Driver needed on client

INSTALLING THE ODBC DRIVER Steps for Configuring the ODBC Driver Creating DSN(Data Source Name) Click on the ODBC Data Source icon in the control panel. Click on the add button in the ODBC Data Source Administrator dialog box.

3. Select the SQL Server option from the list and click on Finish in the Create New Data Source. Dialog box.

4. Type a name for the data source in the Name text box, specify the name of the server you want to connect to, and then, click on the Next button.

5. Select the with SQL Server authentication using login ID and password entered by the user option from the Microsoft SQL Server DSN Configuration dialog box and then click on the Next button.

6. Select the database that you want to use and click on the Next button.

7. Click on the Finish button.

8. Click on Test Data Source to check for proper connectivity with the database and then click on OK to end the ODBC set up. Click on OK

Querying A DataBase After Creating DSN load a driver Loading a Driver : we should load the driver into JVM before requesting for a connection. the forName() method from the Class is loading a class into the memory. Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”); Connecting to a Database : The Connection Object represents a connection with a database. Connection con=DriverManager.getConnection(“jdbc.odbc.<dsn>”, ”<username>”,”<pwd>”);

DatabaseMetaData : Contains the details about the Database. String getDriverName() String getDatabaseProductname() String getDatabaseProductVersion() Statement Object : For executing sql statements against the database Statement stat=con.createStatement(); executeQuery() simple select query and returns single ResultSet object. executeUpdate() executes the SQl INSERT,UPDATE and DELETE statements. execute() executes a SQL statement that may return multiple results.

Preparedstatement Object : it contains a set of methods that you can use for sending queries with INPUT parameters. stat=con.preparedStatement(“select 8 from employees where extension=?”); CallableStatement Object : it contains functionality for calling a stored procedure. You can handle both INPUT and OUTPUT parameters. ResultSet Object : it contains the collection of selected from the database. boolean next() boolean previous() boolean first() boolean Last() String getString(String fieldname) int getInt(int fieldno)