Introduction to JDBC (Java Database Connectivity).

Slides:



Advertisements
Similar presentations
CE203 - Application Programming Autumn 2013CE203 Part 51 Part 5.
Advertisements

Java Database Connectivity (JDBC). 2/24 JDBC (Java DataBase Connectivity) - provides access to relational database systems JDBC is a vendor independent.
1 JDBC Java Database Connectivity. 2 c.pdf
JDBC Overview Autumn 2001 Lecturer: C. DeJong. Relational Databases widespread use used via SQL (Structured Query Language) freely available powerful.
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.
EmbeddedSQL: 1 Impedance Mismatch Problem Problem : How to connect SQL statements with conventional programming languages Different models of language.
CSE 190: Internet E-Commerce Lecture 13: Database code.
JDBC CS 122. JDBC zJava Database Connectivity zDatabase Access Interface Õprovides access to a relational database (by allowing SQL statements to be sent.
Advanced OOP MCS-3 OOP BSCS-3 Lecture # 11. DATABASE CONNECTIVITY IN JAVA JDBC Programming JDBC (Java Database Connectivity) is the specification of a.
Overview 1. What is JDBC? 2. The JDBC-ODBC Bridge 3. JDBC Pseudocode 4. simpJDBC.java.
Lab: JDBC 1 Computer Engineering Lab III v Objective –to give some background on JDBC to help with the lab exercises , Semester 1,
CIS 270—App Dev II Big Java Chapter 22 Relational Databases.
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
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.
JDBC Java Database Connectivity. What is an RDBMS? Relational database management system. There are other kinds of DBMS. Access is a GUI on a JET RBDMS.
Think Possibility Integrating Web Applications With Databases.
Helena Pomezná, ciz034 St. skupina: L392 FEI, VŠB-TUO Ak. rok. 2002/2003 Download:
Chapter 7 PHP Interacts with Ms. Access (Open DataBase Connectivity (ODBC))
June 1, 2000 Object Oriented Programming in Java (95-707) Java Language Basics 1 Lecture 8 Object Oriented Programming in Java Advanced Topics Java Database.
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.
Beginning Databases with JDBC Mike Bradley Adapted from and notes by Kevin Parker, Ph.D.
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.
Java Utility Classes CS 21b. Some Java Utility Classes Vector Hashtable StringTokenizer * import java.util.*;
CIS 270—Application Development II Chapter 25—Accessing Databases with JDBC.
Georgia Institute of Technology Making Text for the Web part 5 Barb Ericson Georgia Institute of Technology March 2006.
JDBC (Java Database Connectivity) SNU OOPSLA Lab. October 2005.
Introduction to JDBC Michelle Lee, Ye Wu & Jeff Offutt SWE 432 Design and Implementation of Software for the Web.
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.
1 JDBC Aum Amriteshwaryai Namah. 2 2 JDBC – Java DataBase Connectivity.
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.
Chapter 25 Databases. Chapter Scope Database concepts Tables and queries SQL statements Managing data in a database Java Foundations, 3rd Edition, Lewis/DePasquale/Chase25.
JDBC Establish a connection with a database or access any tabular data source Send SQL statements Process the results Two major sets of interfaces: JDBC.
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.
Presentation On How To Create Connection To A Database.
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.
DATABASE CONNECTIVITY TO MYSQL. Introduction =>A real life application needs to manipulate data stored in a Database. =>A database is a collection of.
DataBases and SQL INFSY 547 Spring Course Wrap Up April 12: Complete Work on Servlets Review of Team Projects Close of Portfolio Work April 19:
PHP Programming. Topics Database Handling (MySQL, MSSQL, ODBC)
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.
JDBC (Java Database Connectivity)
JDBC Java DataBase Connectivity. Loading the driver import java.sql.*... Class.forName("org.postgresql.Driver")‏
Database Programming With Java & JDBC Reading: DD Ch. 18, pp al/jdbc/index.html, or anything covering JDBC.
1 JDBC – Java Database Connectivity CS , Spring 2010.
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.
JDBC Statements The JDBC Statement, CallableStatement, and PreparedStatement interfaces define the methods and properties that enables to send SQL or PL/SQL.
JDBC. What is JDBC JDBC is an acronym for –Java Data Base Connectivity. It allows java program to connect to any database.
Lec - 14.
JDBC Database Management Database connectivity
JDBC – Java Database Connectivity
HW#4 Making Simple BBS Using JDBC
Objectives In this lesson, you will learn about:
JDBC – ODBC DRIVERS.
Java Database Connectivity
Bolat Azamat, Kim Dongmin
Java API for Database Connectivity
JDBC Example.
Presentation transcript:

Introduction to JDBC (Java Database Connectivity)

Registering ODBC Data Source Before using Java to access to MS Access DB, register the DB as an ODBC data source.

DB Registration Continued To register Names.mdb as an ODBC data source, use the following steps. 1.To open Data Sources (ODBC), click Start, click Control Panel, and then click Administrative Tools. Double-click Data Sources (ODBC). 2.Click Add

DB Registration Continued 3.Choose Microsoft Access Driver. 4.Click Finish.

DB Registration Continued 5.Type the Data Source Name 6.Select the database to use.

Creating a Database Step 1: Load the JDBC-ODBC bridge Step 2: Connect to a data source Step 3: Send SQL statements to create the table. Step 4: Use the table using SQL

1. JDBC-ODBC Bridge Method 1 Class.forName (“sun.jdbc.odbc.JdbcOdbcDriver”); Method 2 java -Djdbc.drivers =sun.jdbc.odbc.JdbcOdbcDriver AProgram

2. Connect to a data source JDBC data source (DB) is given in URL. URLs should be in the following form jdbc:odbc:data-source-name Use DriverManager class, to connect to a URL DriverManager selects the appropriate driver 1. // database name = ClassList 2. String url = “jdbc:odbc:ClassList”; 3. String uname = “anonymous”; 4. String pword = “guest”; 5. Connection = DriverManager.getConnection(url,uname,pword);

3. Creating a Database Ask for a Statement object Execute the SQL statement to create a table. 1. Statement stmt = con.createStatement(); 2. stmt.execute( "create table Names(“id integer” 3. + “fname varchar (32),“ + “lname varchar(32));" ); In the above, create table Names( id integer, fname varchar (32), lname varchar (20)); is a SQL statement.

4. Insert a Value After you have created the table, you can the insert the appropriate values such as: 1. String st1 = “insert into Names values (1, ‘Angelia', ‘Jolie');”; 2. stmt.execute(st1);

4. Getting Information from a Database Use executeQuery() method of a Statement object. To store the return value of the query, use the ResultSet class. 1. ResultSet result = stmt.executeQuery( "SELECT * from Names;");

Class ResultSet 1 The general form of a result set is a table. It has 1. column headings 2. corresponding values Example idfnamelname 1AngelinaJolie 2ArnoldSchwartz

Class ResultSet 2 Examine the ResultSet by: Moving to the first row of data. result.next(); Extracting data from the columns of that row. String fname = result.getString (“fname"); int cups = result.getInt (“id");

JDBC Exception Types SQLException Basis of all JDBC exceptions SQLWarning Noncritical error and is not thrown Extract this messages through the getWarnings methods of Connection, ResultSet, and Statement DataTruncation Special type of SQLWarning To detect, use instanceof DataTruncation check on each SQLWarning