Distributed Application Development B. Ramamurthy.

Slides:



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

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.
1 JDBC Java Database Connectivity. 2 c.pdf
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 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.
UFCE4Y UFCE4Y-20-3 Components and Services Julia Dawson.
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:
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.
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
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.
Helena Pomezná, ciz034 St. skupina: L392 FEI, VŠB-TUO Ak. rok. 2002/2003 Download:
Java Database Connectivity Vijayan Sugumaran Department of DIS Oakland University.
© 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.
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.
Dr R R DOCSIT, Dr BAMU. Basic Java : Introduction to JDBC 2 Objectives of This Session State what is Java Database Connectivity State different.
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 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.
 What software components are required?  How do I install the Oracle JDBC driver?  How do I connect to the database?  What form is the data in and.
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.
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.
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  Oracle Corporation, All rights reserved. 7 Accessing a Database Using SQLJ.
Computer Science [3] Java Programming II - Laboratory Course Lab 9: Accessing Databases with JDBC Instructions on Setting Accesses Connecting to and Querying.
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.
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.
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.
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.
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.
In the Name Of Almighty Allah. Java Application Connection To Mysql Created by Hasibullah (Sahibzada) Kabul Computer Science Faculty Afghanistan.
Intro to JDBC Joseph Sant Applied Computing and Engineering Sciences Sheridan ITAL.
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.
DEPTT. OF COMP. SC & APPLICATIONS
Interacting with Database
Lec - 14.
JDBC Database Management Database connectivity
JDBC.
Interacting with Database
MSIS 655 Advanced Business Applications Programming
Java Database Connectivity
JAVA DATABaSE CONNECTIVITY
Java API for Database Connectivity
Presentation transcript:

Distributed Application Development B. Ramamurthy

Working with Oracle Use the Oracle DBMS on UB machines. Information about this is available here.here You can access UB db from your laptop as long you have enabled VPN and installed the appropriate driver and connected the data source. (and of course you have an internet connectivity).

Standard Access to DB APPLICATIONAPPLICATION DRIVERMGRDRIVERMGR DBMS Driver 1 DBMS Driver 2 DBMS Driver 3 DBMS 1 DBMS 2 DBMS 3 DB

ODBC Architecture Application Class1Class2 Driver Manager DriverType1DriverType2DriverType3 DataSource2 DataSource1 DataSource3 ODBC

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

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.

An Example ApplicationDriverManager Access drivermySQL driverOracle driver odbc standard API

Application in Java Application in Java DriverManager Sybase drivermSQL driverInformix driver odbc standard API jdbc API

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”

Java Support for SQL Java supports embedded SQL. Also it provides an JDBC API as a standard way to connect to common relational databases. Java.sql package and an extensive exception hierarchy.

Data Source Local relational database; Ex: Oracle Remote relational database on a server; Ex: InfoSource On-line information service; Ex: Dow Jones, Customer database

SQL Statements SELECT {what} FROM {table name} SELECT {what} FROM {table name} WHERE {criteria} SELECT {what} FROM {table name} WHERE {criteria} ORDER BY {field} Others Queries are embedded as strings in a Statement object.

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.

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

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.

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.

Statement interface Statement interface is implemented by the connection object. Statement object provides the workspace for SQL query, executing it, and retrieving returned data. Types: Statement, PreparedStatement, CallableStatement

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.

JDBC Application Architecture Application Connection Driver Manager Driver DataSource Statement Result Set

JDBC Programming Steps Import necessary packages; Ex: import java.sql.*; Include jdbc classes as a jar library. Connect to the data source using “identifying” string, a user name and password. Allocate Connection object, Statement object and ResultSet object Execute query using Statement object Retrieve data from ResultSet object Close Connection object.

Identifying Data Sources It is specified using URL format. : : Example(for local source): jdbc:odbc:tech_books Alternatively, for remote connection,

Connecting to a database on Netbeans 1.Add the driver jar file to the library for inclusion during compiling and building of the executable. 2.Add a new driver (jdbc:odbc) to the databases tab. 3.Open connection to the data source (in this case to an Oracle 11g instance) 4.On successful connection you can view the data source details (tables etc.). 5.You can programmatically access the content of the database from a Java program. 6.You can execute SQL command from the source editor window.

Connecting to UB’s Oracle 11g DB Add the oracle driver to the library jars of your project. Here is the oracle driver:oracle driver In order to load the JDBC driver in your Java programs, include the line: Class.forName("oracle.jdbc.driver.OracleDriver"); try { Class.forName ("oracle.jdbc.driver.OracleDriver"); } catch (ClassNotFoundException e){ System.out.println("Could not load the JDBC driver. Check your CLASSPATH."); System.exit(0); }

Connecting to UB’s Oracle Use this connection string syntax to connect to AOS: Connection con = DriverManager.getConnection("jdbc:oracle:thin:"+user+"/"+ Rest of the programming is similar to how we programmed the Derby database..no difference!! Essentially different drivers shield the differences in the databases, exactly similar to how the device drivers operate!