DATABASE DESIGN I - 1DL300

Similar documents
Java Database Connectivity

Databases 2012 Embedded SQL

Instructor: Jinze Liu. Fall 2008

CSC System Development with Java. Database Connection. Department of Statistics and Computer Science. Budditha Hettige

You write standard JDBC API application and plug in the appropriate JDBC driver for the database the you want to use. Java applet, app or servlets

SQream Connector JDBC SQream Technologies Version 2.9.3

SQL: Programming. Announcements (September 25) Motivation. CPS 116 Introduction to Database Systems. Pros and cons of SQL.

Introduction to JDBC. Lecture 12

SQL: Programming Midterm in class next Thursday (October 5)

JDBC Architecture. JDBC API: This provides the application-to- JDBC Manager connection.

Database Programming Overview. COSC 304 Introduction to Database Systems. Database Programming. JDBC Interfaces. JDBC Overview

Introduction to Database Technology Elmasri/Navathe ch 1-2 Padron-McCarthy/Risch ch 1 Sobhan Badiozamany Silvia Stefanova Department of Information Te

INTRODUCTION TO JDBC - Revised spring

ERwin and JDBC. Mar. 6, 2007 Myoung Ho Kim

INTRODUCTION TO JDBC - Revised Spring

Types of Databases. Types of Databases. Types of Databases. Databases and Web. Databases and Web. Relational databases may also have indexes

Accessing databases in Java using JDBC

Unit 3 - Java Data Base Connectivity

Database Application Development

Introduction to Databases

Advanced Programming Techniques. Database Systems. Christopher Moretti

Wentworth Institute of Technology COMP570 Database Applications Fall 2014 Derbinsky. SQL Programming. Lecture 8. SQL Programming

Java Database Connectivity

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Visit for more.

Logging and Recovery. 444 Section, April 23, 2009

Calling SQL from a host language (Java and Python) Kathleen Durant CS 3200

BUSINESS INTELLIGENCE LABORATORY. Data Access: Relational Data Bases. Business Informatics Degree

JDBC 3.0. Java Database Connectivity. 1 Java

Database Application Development

Chapter 4 Application Programs and Object-Relational Capabilities

Unit 2 JDBC Programming

JDBC [Java DataBase Connectivity]

JAVA AND DATABASES. Summer 2018

Database Application Development Part 2 - Chapter

3) execute() Usage: when you cannot determine whether SQL is an update or query return true if row is returned, use getresultset() to get the

Databases and JDBC. by Vlad Costel Ungureanu for Learn Stuff

JDBC drivers are divided into four types or levels. The different types of jdbc drivers are:

Programming in Java

COP4540 TUTORIAL PROFESSOR: DR SHU-CHING CHEN TA: H S IN-YU HA

Database connectivity (II)

Java Database Connectivity (JDBC) 25.1 What is JDBC?

Chapter 13 Introduction to SQL Programming Techniques

1. PhP Project. Create a new PhP Project as shown below and click next

Accessing a database from Java. Using JDBC

SQL in a Server Environment

Chapter 3 DB-Gateways

C:/Users/zzaier/Documents/NetBeansProjects/WebApplication4/src/java/mainpackage/MainClass.java

Chapter 3 DB-Gateways

DB I. 1 Dr. Ahmed ElShafee, Java course

JDBC Programming: Intro

Cyrus Shahabi Computer Science Department University of Southern California C. Shahabi

Application Programming for Relational Databases

The Design of JDBC The Structured Query Language Basic JDBC Programming Concepts Query Execution Scrollable and Updatable Result Sets

Announcements. SQL: Part IV. Transactions. Summary of SQL features covered so far. Fine prints. SQL transactions. Reading assignments for this week

Chapter 3 DB-Gateways

while (rs.next()) { String[] temp_array = {"","",""}; int prodid = rs.getint(1); temp_array[0] = ""+prodid;

Database Application Development

Introduction to JDBC. JDBC: Java Database Connectivity. Why Access a Database with Java? Compilation. Six Steps. Packages to Import

Kyle Brown Knowledge Systems Corporation by Kyle Brown and Knowledge Systems Corporation

DataBase Lab JAVA-DATABASE CONNECTION. Eng. Haneen El-masry

Chair of Software Engineering. Java and C# in Depth. Prof. Dr. Bertrand Meyer. Exercise Session 9. Nadia Polikarpova

Persistency Patterns. Repository and DAO

Part I: Stored Procedures. Introduction to SQL Programming Techniques. CSC 375, Fall 2017

DATABASE DESIGN I - 1DL300

COMP102: Introduction to Databases, 23

MySQL, Postgres, SQLite, Oracle, Sybase, DB2, each column is an "attribute" common to all rows

DATABASE DESIGN I - 1DL300

Lecture 27 10/30/15. CMPSC431W: Database Management Systems. Instructor: Yu- San Lin

Database Application Programs PL/SQL, Java and the Web

Database Programming. Week 9. *Some of the slides in this lecture are created by Prof. Ian Horrocks from University of Oxford

WEB SERVICES EXAMPLE 2

Advances in Programming Languages

Database in Applica.on Development. Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata

UNIT-3 Java Database Client/Server

SQL Environment: Module Types. System Aspects of SQL. SQL Environment: Introduction. SQL Environment: Introduction. SQL Environment: Privileges

EJB - ACCESS DATABASE

Java Database Connectivity

Non-interactive SQL. EECS Introduction to Database Management Systems

Enterprise Java Unit 1- Chapter 6 Prof. Sujata Rizal

Advances in Programming Languages

Database Applications (15-415)

Java and the Java DataBase Connectivity (JDBC) API. Todd Kaufman April 25, 2002

DATABASE DESIGN I - 1DL300

Outline. Lecture 10: Database Connectivity -JDBC. Java Persistence. Persistence via Database

Java E-Commerce Martin Cooke,

More Database Programming. CS157A Chris Pollett Nov. 2, 2005.

JDBC. Sun Microsystems has included JDBC API as a part of J2SDK to develop Java applications that can communicate with databases.

ITCS Implementation. Jing Yang 2010 Fall. Class 14: Introduction to SQL Programming Techniques (Ch13) Outline

e-pg Pathshala Subject: Computer Science Paper: Web Technology Module: JDBC INTRODUCTION Module No: CS/WT/26 Quadrant 2 e-text

CS221 Lecture: Java Database Connectivity (JDBC)

Database Application Development

The Web Application Developer s. Red Hat Database. View. October 30, Webcast. Patrick Macdonald, Fernando Nasser. Red Hat Database Engineering

DATABASE DESIGN I - 1DL300

JDBC. Oracle ODBC SP API SP API. SQL server C function calls. SQL server ODBC SP API. Oracle DSN Oracle ODBC Oracle

Brekeke PBX Version 3 IVR Developer s Guide Brekeke Software, Inc.

Database systems in 21 minutes

An IBM Rational Software TechNote

Database Access. Rick Cattell JavaSoft

Tiers (or layers) Separation of concerns

Transcription:

DATABASE DESIGN I - 1DL300 Fall 2010 An introductory course on database systems http://www.it.uu.se/edu/course/homepage/dbastekn/ht10/ Manivasakan Sabesan Uppsala Database Laboratory Department of Information Technology, Uppsala University, Uppsala, Sweden Manivasakan Sabesan- UDBL - IT - UU 2010-12-06 1

Database API:s (Elmasri/Navathe ch. 12) (Padron-McCarthy/Risch ch 20) Manivasakan Sabesan Department of Information Technology Uppsala University, Uppsala, Sweden Manivasakan Sabesan- UDBL - IT - UU 2010-12-06 2

Database user interfaces Textual interfaces Such as BSQL for Mimer WSQL or DbVisualizer including graphical browsing Graphical query-interfaces Most well-known is QBE (Query-By-Example) originally developed by IBM. MS Access uses a QBE variant. SQL application programming interfaces Requires management of sessions, sql statements and some control of query optimization. Call-level interfaces Embedded SQL 2010-12-06 3

Call-Level Interfaces Vendor-specific call-level interfaces An SQL API usually for one or several host languages like C, C++, Java, Fortan, COBOL etc. Support to manage sessions, SQL statements and data conversions SQL Call Level Interface (CLI), The Call Level Interface (CLI) is a standard SQL API created by The Open Group. The API is defined for C and COBOL only. ISBN: 1-85912-081-4, X/Open Document Number: C451, 1995. SQL/CLI Call-Level Interface (SQL/CLI) is an implementation-independent CLI to access SQL databases. SQL/CLI is an ISO standard ISO/IEC 9075-3:1995 Information technology -- Database languages -- SQL -- Part 3: Call-Level Interface (SQL/CLI). The current SQL/CLI effort is adding support for SQL:1999. ODBC (Microsoft) Open Database Connectivity is a standard SQL API. ODBC is based on the Call Level Interface (CLI) specifications from SQL, X/Open (now part of The Open Group), and the ISO/IEC. ODBC was created by the SQL Access Group and released Sept, 1992. JDBC - Java Database Connectivity JDBC is an SQL API for Java (to be strictly correct, JDBC is not an acronym). 2010-12-06 4

The ODBC architecture ODBC API is independent of any one programming language, database system or operating system. 2010-12-06 5

The JDBC architecture JDBC API is independent of (relational) DBMS and operating system 2010-12-06 6

Alt. JDBC architecture (JDBC-ODBC bridge) Makes ODBC accessible from JDBC such that no special JDBC drivers are required. 2010-12-06 7

Programming with SQL CLI interfaces JDBC example The JDBC API (Application Program Interface) is a set of Java interfaces that allow database applications to: open connections to a database, execute SQL statements, and process the results. These include: java.sql.drivermanager, which loads the specific drivers and supports creating new database connections java.sql.connection, which represents a connection to a specific database java.sql.statement, which allows the application to execute a SQL statement java.sql.preparedstatement, which represents a pre-compiled SQL statement java.sql.resultset, controls access to rows resulting from executing a statement 2010-12-06 8

import java.sql.*; JDBC example public class JDBCExample { public static void main(string args[]) { String url = "jdbc:mysubprotocol:mydatasource"; Connection con; String query = "SELECT NAME FROM EMPLOYEE WHERE INCOME > 10000"; Statement stmt; try { Class.forName("myDriver.ClassName"); }catch(java.lang.classnotfoundexception e) { System.err.print("ClassNotFoundException: "); System.err.println(e.getMessage()); } try { con = DriverManager.getConnection(url, "mylogin", "mypassword"); stmt = con.createstatement(); ResultSet rs = stmt.executequery(query); while (rs.next()) { String s = rs.getstring( NAME"); System.out.println(s); } rs.close(); stmt.close(); con.close(); }catch(sqlexception ex) { System.err.print("SQLException: "); System.err.println(ex.getMessage()); }}} 2010-12-06 9

import java.sql.*; JDBC example (prepared statement) public class JDBCExample { public static void main(string args[]) { String url = "jdbc:mysubprotocol:mydatasource"; Connection con; String query = "SELECT NAME FROM EMPLOYEE WHERE INCOME >?; Int incomelimit; PreparedStatement stmt; try { Class.forName("myDriver.ClassName"); }catch(java.lang.classnotfoundexception e) { System.err.print("ClassNotFoundException: "); System.err.println(e.getMessage()); } try { con = DriverManager.getConnection(url, "mylogin", "mypassword"); stmt = con.preparestatement(query); while(...) {... // Code to read lower income limit into incomelimit stmt.setint(1,incomelimit); ResultSet rs = stmt.executequery(); while (rs.next()) { System.out.println(rs.getString( NAME")); }} rs.close(); stmt.close(); con.close(); }catch(sqlexception ex) { System.err.print("SQLException: "); System.err.println(ex.getMessage()); }}} 2010-12-06 10

Embedded SQL Host language include embedded and specially marked SQL statements. Embedded statements are extracted by preprocessor, translated and replaced by database calls, precompiled (prepared) and stored on server. The preprocessed application is then compiled normally Supports dynamic recompilation Reduces optimization cost and can be somewhat simpler than CLI programming. 2010-12-06 11