Advanced Programming Collage of Information Technology University of Palestine, Gaza Prepared by: Mahmoud Rafeek Alfarra Lecture12: Accessing Databases.

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 (JDBC) Use the java.sql package to query and update the database. JDBC is an API that allows java to communicate with.
Distributed Application Development B. Ramamurthy.
1 JDBC Java Database Connectivity. 2 c.pdf
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 C. Shahabi Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California
Java Database Connectivity (JDBC) java.sql package to query and update the database. JDBC is an API that allows java to communicate with a database server.
DT228/3 Web Development Databases. Database Almost all web application on the net access a database e.g. shopping sites, message boards, search engines.
1 Foundations of Software Design Lecture 27: Java Database Programming Marti Hearst Fall 2002.
Databases: Connectivity Dr Andy Evans. Databases Flat file, relational, or object orientated stores of data records and their relationships. Oracle MySQL.
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.
JAVA JDBC JAVA JDBC Java Database Programming Lamiaa Said.
Advanced OOP MCS-3 OOP BSCS-3 Lecture # 11. DATABASE CONNECTIVITY IN JAVA JDBC Programming JDBC (Java Database Connectivity) is the specification of a.
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. –
1 Web Database Processing. Web Database Applications Static Report Publishing a report is prepared from a database application and exported to HTML DB.
JDBC Vs. Java Blend Presentation by Gopal Manchikanti Shivakumar Balasubramanyam.
1 CSC 440 Database Management Systems JDBC This presentation uses slides and lecture notes available from
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.
Jaeki Song JAVA Lecture 11 Java Database Connectivity.
Lecture On Database Analysis and Design By- Jesmin Akhter Lecturer, IIT, Jahangirnagar University.
Java Database Connectivity (JDBC) Introduction to JDBC JDBC is a simple API for connecting from Java applications to multiple databases. Lets you smoothly.
Views, Indexes and JDBC/JSP tutorial Professor: Dr. Shu-Ching Chen TA: Haiman Tian 1.
CIS 270—Application Development II Chapter 25—Accessing Databases with JDBC.
Movie Manager by Patrick Wesley and Chris Grey Internet Database Project for CS 8630 – Summer 2004 Dr. Guimaraes.
M1G Introduction to Database Development 6. Building Applications.
Georgia Institute of Technology Making Text for the Web part 5 Barb Ericson Georgia Institute of Technology March 2006.
MySQL, Java, and JDBC CSE 3330 Southern Methodist University.
CSC 411/511: DBMS Design Dr. Nan WangCSC411_L12_JDBC_MySQL 1 MySQL and JDBC.
JAVA Database Access. JDBC The Java Database Connectivity (JDBC) API is the industry standard for database- independent connectivity between the Java.
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,
Object-Oriented Software How does it differ from procedural? How is it similar to procedural? Why has it become so popular? Does it replace or supplement.
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.
MIS 3023 Business Programming II Professor: Akhilesh Bajaj Introduction to JDBC © Akhilesh Bajaj, All Rights Reserved.
Index and JDBC/JSP tutorial Professor: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
Hibernate 3.0. What is Hibernate Hibernate is a free, open source Java package that makes it easy to work with relational databases. Hibernate makes it.
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.
Copyright  Oracle Corporation, All rights reserved. 6 Accessing a Database Using the JDBC API.
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.
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.
JDBC - Connection The programming involved to establish a JDBC connection is fairly simple. Here are these simple four steps − Import JDBC Packages: Add.
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.
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.
225 City Avenue, Suite 106 Bala Cynwyd, PA , phone , fax Connecting to a Database.
A CCESSING D ATABASES WITH JDBC CH 24 C S 442: A DVANCED J AVA P ROGRAMMING.
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.
Introduction to JDBC Instructor: Mohamed Eltabakh 1.
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.
1 JDBC – Java Database Connectivity CS , Spring 2010.
JDBC. Database is used to store data permanently. These days almost all Applications needs database to store its data persistently. Below are the most.
JDBC.
Fundamental of Databases
DEPTT. OF COMP. SC & APPLICATIONS
ODBC, OCCI and JDBC overview
JDBC.
Prof: Dr. Shu-Ching Chen TA: Sheng Guan
MSIS 655 Advanced Business Applications Programming
Java Database Connectivity
JAVA DATABaSE CONNECTIVITY
Java Chapter 6 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Advanced Programming Collage of Information Technology University of Palestine, Gaza Prepared by: Mahmoud Rafeek Alfarra Lecture12: Accessing Databases with JDBC

2 Outlines يقول ابن مسعود: مرحبًا بالشتاء, تتنزل فيه البركة و يطول فيه الليل للقيام و يقصر فيه النهار للصيام

3 Outlines  SQL’s statement overview  Java DB connectivity (JDBC)  Connecting to and Querying a Database  More

4  A database is an organized collection of data.  There are many different strategies for organizing data to facilitate easy access and manipulation.  A database management system (DBMS) provides mechanisms for storing, organizing, retrieving and modifying data for many users.  Database management systems allow for the access and storage of data without concern for the internal representation of data. Introduction

5  Some popular relational database management systems (RDBMSs) are 1. Microsoft SQL Server, 2.Oracle, 3.Sybase, 4.IBM DB2, 5.MySQL. Introduction

6  Java programs communicate with databases and manipulate their data using the JDBC™API.  A JDBC driver enables Java applications to connect to a database in a particular DBMS and allows programmers to manipulate that database using the JDBC API.  JDBC is almost always used with a relational database.  However, it can be used with any table-based data source. Java DB connectivity 'JDBC'

7 SQL’s statement overview

8  The hardest thing about using JDBC is usually getting the JDBC drivers to connect to the database in the first place.  The principle difficulty is because we need to get three different things working together: 1.Our Oracle database, 2.Our Java development environment, and 3.The JDBC drivers to connect the Oracle database and our Java programs. Connecting to Database Oracle DB JDE JDBC

9  There are numerous options and alternatives for connecting, many of which you can explore in more reading, but for now we'll start with the basics.  These are the steps required to connect to the database:  Setting up the Oracle, Java, and JDBC environment  Importing the JDBC classes we need  Loading and registering the JDBC driver  Getting a Connection object from the driver Connecting to Database

10 Setting up JDBC enviro.  You should set your CLASSPATH environment variable to include the Oracle JDBC driver.  This is provided by Oracle in the [ORACLE_HOME]\jdbc\lib directory.  If you are using Windows NT/2000/XP, you can set CLASSPATH using the System applet in the Control Panel.  If a CLASSPATH variable does not already exist, start by choosing New. Type in CLASSPATH as the variable name and.;\[ORACLE_HOME] \jdbc\lib\classes12.zip as the variable value.

11 Setting up JDBC enviro

12 Importing the JDBC Classes  The Java compiler needs to import the JDBC classes we will be using.  At the top of our Java source file, we need to include the following import statements:  If the CLASSPATH hasn't been set correctly, the second import above will generate a complaint from the compiler, claiming that the package oracle.jdbc.driver does not exist. import java.sql.*; import oracle.jdbc.driver.*;

13 Loading and Registering the JDBC Driver  To load the JDBC driver requires two steps: 1.Loading the class and 2.Registering it with the DriverManager.  The DriverManager will automatically load the driver for us. DriverManager.registerDriver(new oracle.jdbc.OracleDriver());

14 Getting a Connection  The DriverManager is responsible for connecting us to resources.  When we want to use a resource, such as a database, we construct a Uniform Resource Locater (URL) and use it to request a Connection object from the DriverManager.  The DriverManager will search the registered drivers for one that can accept our URL.

15 Getting a Connection  Oracle provides two JDBC drivers: 1.An OCI driver and 2.A pure-Java thin driver;  Each of these accepts several different types of URLs.  We will use the thin driver with a URL of the following format: : : "

16 Sample Connection Program // TestConnection.java – Load JDBC and connect to database import java.sql.*; import oracle.jdbc.driver.*; public class TestConnection { public static void main(String [] vars){ Connection conn; try { DriverManager.registerDriver(new oracle.jdbc.OracleDriver()); // The following needs to be edited with your database specifics: conn = DriverManager.getConnection( "scott", "tiger"); } catch (SQLException e) { System.out.println("Caught: " + e); System.exit(1); } } }

17 Next Lecture isa 1.Executing SQL Statements 2.Executing SQL Queries 3.Large Objects—BLOBs and CLOBs 4.Stored Procedures 5.RowSet Interface

18 Thank You … Questions?!