Java Database Connectivity By: Abe Marji CS616. Agenda 1.Quick Review of Databases 2.What is SQL? 3.What is JDBC? 4.Advanced Functions of JDBC 5.Summary.

Slides:



Advertisements
Similar presentations
Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
Advertisements

Murach’s Java SE 6, C21© 2007, Mike Murach & Associates, Inc.Slide 1.
Java Database Connectivity (JDBC). 2/24 JDBC (Java DataBase Connectivity) - provides access to relational database systems JDBC is a vendor independent.
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.
Object Oriented Programming Java Java’s JDBC Allows access to any ANSI SQL-2 DBMS Does its work in terms of SQL The JDBC has classes that represent:
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 32 Java Database.
JDBC Overview Autumn 2001 Lecturer: C. DeJong. Relational Databases widespread use used via SQL (Structured Query Language) freely available powerful.
1 Lecture 29 More on JDBC Overview  Objectives of this lecture  JDBC and its Drivers  Connecting to Databases (Java’s Connection class)  Querying a.
1 Foundations of Software Design Lecture 27: Java Database Programming Marti Hearst Fall 2002.
JAVA JDBC JAVA JDBC Java Database Programming Lamiaa Said.
JDBC / ODBC JDBC is the java API that facilitate interaction of a java application with the DBMS. FIRST APPROACH:
Introduction to JDBC (Java Database Connectivity).
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. –
Getting connected.  Java application calls the JDBC library.  JDBC loads a driver which talks to the database.  We can change database engines without.
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.
Helena Pomezná, ciz034 St. skupina: L392 FEI, VŠB-TUO Ak. rok. 2002/2003 Download:
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.
© Wang Bin 2004 JDBC ----Java Database Connectivity.
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.*;
MySQL, Java, and JDBC CSE 3330 Southern Methodist University.
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.
MIS 3023 Business Programming II Professor: Akhilesh Bajaj Introduction to JDBC © Akhilesh Bajaj, All Rights Reserved.
JDBC Java and Databases. RHS – SOC 2 JDBC JDBC – Java DataBase Connectivity An API (i.e. a set of classes and methods), for working with databases in.
Advanced SQL: Cursors & Stored Procedures
JDBC Enterprise Systems Programming. JDBC  Java Database Connectivity  Database Access Interface provides access to a relational database (by allowing.
Chapter 8 Databases.
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.
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  Oracle Corporation, All rights reserved. 7 Accessing a Database Using SQLJ.
Java Database Connectivity. Java and the database Database is used to store data. It is also known as persistent storage as the data is stored and can.
Copyright © 2002 ProsoftTraining. All rights reserved. Building Database Client Applications Using JDBC 2.0.
Course FAQ’s I do not have any knowledge on SQL concepts or Database Testing. Will this course helps me to get through all the concepts? What kind of.
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.
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.
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:
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.
Basics of JDBC Session 14.
Advanced Java Session 5 New York University School of Continuing and Professional Studies.
Database Programming With Java & JDBC Reading: DD Ch. 18, pp al/jdbc/index.html, or anything covering JDBC.
JDBC Java and Databases. SWC – JDBC JDBC – Java DataBase Connectivity An API (i.e. a set of classes and methods), for working with databases in.
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.
CS320 Web and Internet Programming Database Access with JDBC Chengyu Sun California State University, Los Angeles.
Database: JDBC Overview
DEPTT. OF COMP. SC & APPLICATIONS
CS3220 Web and Internet Programming Database Access with JDBC
Lec - 14.
JDBC Database Management Database connectivity
CS320 Web and Internet Programming Database Access with JDBC
Database JDBC Overview CS Programming Languages for Web Applications
Advanced Web Automation Using Selenium
Prof: Dr. Shu-Ching Chen TA: Sheng Guan
Client Access, Queries, Stored Procedures, JDBC
Objectives In this lesson, you will learn about:
Java Database Connectivity
Java Chapter 6 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Java Database Connectivity By: Abe Marji CS616

Agenda 1.Quick Review of Databases 2.What is SQL? 3.What is JDBC? 4.Advanced Functions of JDBC 5.Summary

What are Databases? A database is a collection of tables, which organizes and stores information The columns each contain a category of information. A table consists of rows (records) of columns (fields) The rows contain the information for each of the categories related to an individual event

Database Samples COL1COL2COL3COL4COL5COL6 ROW1 ROW2 ROW3 ROW4 ROW5 ROW6 ROW7 Columns (Attributes) Rows (Data) DATA Table 1 Table 2 Relationship

What is SQL? SQL is “Structure Query Language” It is considered to be the standard for database handling. SQL provides functions to View, Update, Delete, and Add data to a database. SQL also handles the database structure such as changing the properties of its tables or adding or delete new Tables

Types of SQL Calls SELECT – Queries existing Data UPDATE – Updates existing data INSERT – Adds new data in a table DELETE – Deletes data or tables CREATE – Creates new tables

Samples of SQL Queries A simple example of an SQL statement is Standard SQL Statement: Format: “Function Col from condition” “SELECT * FROM Animal“ Not Case Sensitive: “Select NaMe from ANIMAL“ Data is Case Sensitive: “SELECT * from CUSTOMERS where NAME =‘JOE’” Is different from “SELECT * from CUSTOMERS where NAME =‘Joe’”

SQL Standard Data Types Java typeSQL Type Values CharChar or CharacterString IntInteger32 Bit ShortSmall Integer16 Bit LongBig Integer64 Bit DoubleDouble15 Digits DoubleFloat15 Digits FloatReal7 Digits ByteTiny Integer8 Bits Java.math.BigDecimalNumericFixed Point with Java.math.BigDecimalDecimaldecimal Digits

SQL Data Types – Other Java typeSQL Type Values BooleanBitTrue/False Java.sql.DateDateMonth/Day/Year Java.sql.timeTimeHour / Min / Sec Java.sql.datestampdatestampDate and Time

What is JDBC? JDBC is JAVA Database Connectivity. JAVA Applications uses JDBC to connect to a Database. JDBC API are available from Sun Systems. Different Database Vendors make their own JDBC Drivers.

JDBC Driver Layer Model

Querying through Drivers

Sun’s JDBC/ODBC Bridge

Vendor Specific JDBC Drivers

Creating an ODBC Connection

Typical JDBC Code import java.sql.*; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); a_connection = DriverManager.getConnection ("jdbc:odbc:CS616DB",“admin",“password"); a_statement = a_connection.createStatement(); ResultSet rs = a_statement.executeQuery("SQL Query”);

Sample JDBC Code Static Connection DriverManager.getConnection (String datasource, String userid, String password) Connection a_conn = DriverManager.getConnection(“jdbc:odbc: CS616DB”, “Admin”, “password”);

JDBC Exceptions Exceptions occur in Java when errors occur in SQL code. Catching exceptions means dealing with those errors. You can use several methods to get further information on an SQLException: getSQLState() getErrorCode() getNext Exception() getWarnings()

Flow for JDBC Exceptions

Advanced Functions JDBC has the ability to support Prepared Statements and CALL statements Prepared Statements lets you use one sql statement to run different queries by passing it different parameters. CALL statements allows the developer to use database queries that are created by the Database Admin.

Summary JDBC is used in applications that require database connectivity Different Vendors support various types of JDBC Drivers. JDBC can take advantage of advanced SQL functions/queries using the CALL and Execute procedures()