System Aspects of SQL

Size: px
Start display at page:

Download "System Aspects of SQL"

Transcription

1 System Aspects of SQL SQL Environment User Access Control SQL in Programming Environment Embedded SQL SQL and Java Transactions (Programmers View) SQL Environment: Introduction SQL server Supports operations on database elements Typically runs on large host machine SQL client Supports user connections to server Runs on (different) host machine Connection Channel between client and server 2 1

2 SQL Environment: Introduction Session All SQL operations performed while connection open Current catalog, current schema, authorized user SQL Environment SQL agent SQL Server Connection Session SQL Client Application Module: application program SQL agent: execution of module 3 SQL Environment: Module Types Generic SQL Interface: Module: each query or statement Embedded SQL: SQL statements within host-language program SQL statements pre-processed to function calls Calls executed at run-time True modules: Collection of stored procedures Host language code, SQL code 4 2

3 SQL Environment: ileges User Outside schema, handling implementation dependent Identification by Authorization ID (user name) Role Defines user group Inside schema, handling via SQL statements Identification by Authorization ID (role name) All users: special role PUBLIC Examples: CREATE ROLE Customer; CREATE ROLE Secretary WITH ADMIN Klaus; CREATE ROLE Movie_staff; CREATE ROLE Shop_owner; 5 User Access Control: Introduction Secrecy: Users should not be able to see things they are not supposed to. e.g., A student can t see other students grades. Integrity: Users should not be able to modify things they are not supposed to. e.g., Only instructors can assign grades. Availability: Users should be able to see and modify things they are allowed to. 6 3

4 User Access Control: Introduction Security policy specifies authorization Security mechanism enforces a security policy Two mechanisms at DBMS level Discretionary access control Concept of privileges for objects (tables and views) Mechanisms for giving and revoking users privileges Mandatory access control System-wide policies for DBS DB object have security class Rules on security classes govern access Used for specialized (e.g., military) applications 7 User Access Control: ileges ileges Right to perform SQL statement type on objects Assigned to roles (authorization IDs) Creator of object: all privileges DBMS: management of privileges and access rights ilege types: SELECT on table or view INSERT on table or view DELETE on table or view UPDATE on table or view REFERENCES: right to refer to relation in constraint USAGE: (SQL-92) right to use specified domain ALL PRIVILEGES: short form for all privileges 8 4

5 User Access Control: ileges Example INSERT INTO Format(name) SELECT format FROM Tape t WHERE t.format NOT IN (SELECT name FROM format); ileges: SELECT on Tape SELECT on Format INSERT on Format 9 User Access Control: ileges Grant privilege GRANT <privileges> ON <object> TO <users> [WITH GRANT OPTION] GRANT OPTION: Right to pass privilege on to other users Only owner can execute CREATE, ALTER, and DROP ilege to SELECT particular columns in a table GRANT <privileges> ON <tablename(<attributenames>)> TO <users> [WITH GRANT OPTION] 10 5

6 User Access Control: ileges Examples: GRANT INSERT, SELECT ON Movie TO Klaus Klaus can query Movie or insert tuples into it. GRANT DELETE ON Movie TO shop_owner WITH GRANT OPTION Anna can delete tuples, and also authorize others to do so GRANT UPDATE (pricepday) ON Movie TO movie_staff Staff can update (only) the price field of Movie tuples GRANT SELECT ON MovieView TO Customers This does NOT allow the customers to query Movie directly! 11 User Access Control: ileges on views Creator has privilege on view if privilege on all underlying tables Creator loses SELECT privilege on underlying table view is dropped Creator loses a privilege on underlying table creator loses privilege on view Creator loses a privilege held with grant option on underlying table users who were granted that privilege on the view lose privilege on view 12 6

7 User Access Control: ileges Revoke privilege Core SQL:1999 REVOKE <privileges> ON <object> FROM <users> RESTRICT RESTRICT: only revoke if non of the privileges have been granted by these users ilege given from different users must be revoked from all users to loose privilege 13 User Access Control: Examples Owner: GRANT Update ON Movie TO Klaus; Owner: GRANT Update ON Movie TO Anna; owner Klaus Anna Movie Owner: REVOKE Update ON Movie FROM Klaus RESTRICT; owner Klaus Anna Movie 14 7

8 User Access Control: Examples Owner: GRANT Update ON Movie TO Klaus WITH GRANT OPTION; Klaus: GRANT Update ON Movie TO Anna; owner Klaus Anna Movie Grant Owner: REVOKE Update ON Movie FROM Klaus RESTRICT; owner Klaus Anna Movie Grant Command fails! 15 User Access Control: ileges Revoke privilege enhanced SQL:1999 REVOKE [GRANT OPTION FOR] <privileges> ON <object> FROM <users> {RESTRICT CASCADE} CASCADE: revoke from all users that have been granted the privilege by these users RESTRICT: only revoke if non of the privileges have been granted by this user 16 8

9 User Access Control: Examples Owner: GRANT Update ON Movie TO Klaus WITH GRANT OPTION; Klaus: GRANT Update ON Movie TO Anna; owner Klaus Anna Movie Grant Owner: REVOKE Update ON Movie FROM Klaus CASCADE; owner Klaus Anna Movie 17 User Access Control: Examples Owner: GRANT Update ON Movie TO Klaus WITH GRANT OPTION; Klaus: GRANT Update ON Movie TO Anna; owner Klaus Anna Movie Grant Owner: REVOKE GRANT OPTION FOR Update ON Movie FROM Klaus CASCADE; owner Klaus Anna Movie 18 9

10 User Access Control: Examples Owner: GRANT Update ON Movie TO Klaus WITH GRAND OPTION; Owner: GRANT Update ON Movie TO Anna; Klaus: GRANT Update ON Movie TO Anna; owner Movie Klaus Anna Owner: REVOKE GRANT OPTION FOR Update ON Movie FROM Klaus CASCADE; owner Movie Klaus Anna 19 User Access Control: Object owners Schema owner: Right for create, drop, alter (no privilege, not grantable) All privileges on schema objects Object creator/owner: Create statement: current authorizationid is owner Enhanced SQL:1999 : owner needn't be creator Current user privileges in Oracle: SQL> SQL> SELECT * FROM FROM session_privs; PRIVILEGE CREATE SESSION ALTER ALTER SESSION CREATE TABLE TABLE

11 SQL in Programs: Introduction SQL Sub-language for data access Efficient database operations Host language: Control structures Complex computations User interface: output formatting, forms Transactions: DB interactions as unit of work SQL and host language needed 21 SQL in Programs: Impedance Mismatch Impedance Mismatch: differing data model of SQL and host language Problems: Set oriented operations vs manipulation of individuals Interconnection of program variables and SQL statements Compilation time of embedded SQL-statements 22 11

12 SQL in Programs: Program/DBS Communication 1. Fourth Generation Languages (4GL) Decreasing importance 2. Module Languages Standardized in SQL: Call level interface Most important approach Standardized in SQL: Component architectures Hiding the details of DB interaction Example: Enterprise Java Beans (EJB) 23 SQL in Programs: 1. 4GL Underlying assumption: application programs algorithmically simple sophisticated output formatting needed difficult to switch between different DBS Technical concept: Client workstation (presentation, requests, GUI) Database server Decreasing importance Proprietary protocol 24 12

13 SQL in Programs: 2. Modules Parameterized modules of SQL statements Standardized in SQL:1999 Compiled for a particular language Linked to application program Language Examples: COBOL, C, ADA,... Disadvantages: SQL code hidden in application and vice versa Not widely used Used in stored procedures (e.g., Oracle PL/SQL) Executed under control of DBS 25 SQL in Programs: 2. Modules (cont) Example: Returned state value Program Language variables MODULE demo demo NAMES NAMES are are ascii ascii LANGUAGE FORTRAN SCHEMA movie_db AUTHORIZATION PROCEDURE discount_op (SQLSTATE, :title VARCHAR(40), :discount DECIMAL(3,2)) UPDATE Movie Movie M SET SET pricepday = pricepday - :discount WHERE WHERE M.title = :title; PROCEDURE customerstate (SQLSTATE, :customer INTEGER) SELECT movie_id,tape_id,from_date FROM FROM Tape Tape T, T, Rental R WHERE WHERE R.member = customer AND AND R.tape_id = T.id; T.id; 26 13

14 SQL in Programs: 3. Call level interface Interface in standard programming languages Proprietary library routines, API Embedded C / Java /.. Standardized language extensions Standardized API Open Database connection (ODBC), Java Database Connectivity (JDBC) 27 SQL in Programs: 3. Call level interface Language/DBS specific library of procedures Example: MySQL C API Buffer for transferring commands and results API data types, e.g., MYSQL handle for db connections MYSQL_RES result set structure API functions, e.g., mysql_real_query() mysql_real_query(mysql *mysql, const char *query, unsigned int querylength) 28 14

15 SQL in Programs: Embedded SQL Direct SQL: SQL interpreter accepts and executes SQL commands SQL in host language: Program in programming language (C, Java, ) Parts of program in SQL statements Most implementations: call level interface used Most popular: Embedded C (Oracle: PRO*C) Java support SQLJ = Embedded Java JDBC = Standardized call interface for Java 29 SQL in Programs: Embedded SQL Program with "native" and SQL-like statements Pre-compiler = Preprocessor creates native code Calls to DBS resources included Programmer: embedded SQL or function calls Host language + Embedded SQL SQL library Preprocessor Host language + Function Calls Host language compiler Object-code program 30 15

16 SQL in Programs: Static/dynamic embedding Static embedding: SQL commands known in advance SQL-compilation and language binding at pre-compile time Dynamic SQL: SQL-String compiled at runtime variable bindings at runtime 31 SQL in Programs: Embedded SQL Concepts: Well defined type mapping (for different languages) Syntax for embedded SQL statements EXEC SQL {SELECT title FROM...} Binding to host language variables EXEC SQL {SELECT id FROM Movie WHERE titel = :titlestring};... Exception handling WHENEVER <condition> <action> SQLSTATE 32 16

17 SQL in Programs: Embedded SQL SQL / Host Language Interface: Embedded SQL-statement: EXEC SQL <sql statement> Shared variables: :<variablename> (access in SQL) <variablename> (access in host language) Exception handling: SQLSTATE (SQL function execution status) e.g., no problem answer tuple not found 33 SQL in Programs: Embedded SQL Shared variable declaration Syntax: EXEC SQL BEGIN DECLARE SECTION; EXEC SQL END DECLARE SECTION; Declaration in host language Use variable types in common Example: EXEC SQL BEGIN DECLARE SECTION; integer movie_number; integer tape_number; EXEC SQL END DECLARE SECTION; 34 17

18 SQL in Programs: Embedded SQL Single row results: direct insert into variable Syntax: EXEC SQL SELECT <attributename> INTO :<sharedvariable> FROM <tablenames> WHERE <condition> Multiple row results: Use of cursors on result set 35 SQL in Programs: Cursor concept Important concept Cursor: Name of SQL statement and Handle for processing the result set record by record Defined at runtime Opened at runtime (SQL-statement executed) Used in most language embeddings of SQL e.g., ESQL-C, PL/SQL, JDBC 36 18

19 SQL in Programs: Cursor concept No binding of result attributes to variables Allows traversal of result set row by row 1. Cursor declaration 2. Cursor initialisation 3. Fetch tuples 4. Close cursor no DECLARE yes OPEN FETCH EMPTY? CLOSE 37 SQL in Programs: Cursor concept Cursor declaration: EXEC SQL DECLARE <cursorname> CURSOR FOR <query> Cursor initialisation: EXEC SQL OPEN <cursorname>; binds input variables executes query puts first results into communication area positions cursor before first row of the result set 38 19

20 SQL in Programs: Cursor concept Fetch tuples: EXEC SQL FETCH <cursorname> INTO :<shared variable>; Puts next results into communication area Positions cursor before before next row of the result set Assigns tuple to shared variables Sets SQLSTATE 39 SQL in Programs: Example #include <stdio.h> /* /* declare host variables */ */ EXEC SQL SQL BEGIN DECLARE SECTION; char userid[12] = "ABEL/xyz"; char movie_name[10]; int int movie_number; int int tape_number; char temp[32]; void sql_error(); EXEC SQL SQL END END DECLARE SECTION; /* /* include the the SQL SQL Communication Area */ */ #include <sqlca.h> 40 20

21 SQL in Programs: Example /* /* main program */ */ main() { movie_number = 200; /* /* handle errors */ */ EXEC SQL SQL WHENEVER SQLERROR do do sql_error("oracle error"); /* /* connect to to Oracle */ */ EXEC SQL SQL CONNECT :userid; printf("connected.\n"); 41 SQL in Programs: Example /* /* declare a cursor */ */ EXEC SQL SQL DECLARE movie_cursor CURSOR FOR FOR SELECT m.title FROM movie m, m, tape t WHERE t.id = :tape_number AND AND t.movie_id = m.id; /* /* get get user data */ */ printf( Tape number? "); "); gets(temp); tape_number = atoi(temp); 42 21

22 SQL in Programs: Example /* /* open the the cursor and and identify the the result set set */ */ EXEC SQL SQL OPEN movie_cursor; /* /* fetch and and process data in in a loop exit when no no more data */ */ EXEC SQL SQL WHENEVER NOT NOT FOUND DO DO break; while (1){ EXEC SQL SQL FETCH movie_cursor INTO :movie_name; } 43 SQL in Programs: Example /* /* close cursor before another SQL SQL statement is is executed */ */ EXEC SQL SQL CLOSE movie_cursor; } EXEC SQL SQL COMMIT WORK RELEASE; exit(0); 44 22

23 SQL in Programs: Positioned Update Step through set of rows and update or delete Syntax: Example: EXEC SQL DECLARE <cursorname> CURSOR FOR <query> FOR UPDATE ON <attribute>; WHERE CURRENT OF <cursorname> EXEC SQL DECLARE mycurs CURSOR FOR SELECT id,length,title FROM Movie FOR UPDATE ON length EXEC SQL UPDATE Movie SET lenght = length + 1 WHERE CURRENT OF mycurs; 45 SQL in Programs: Cursor Options Ordering tuples Use ORDER BY in query Cursor motion SCROLL CURSOR Relative to current position: PRIOR/NEXT/RELATIVE<nr> e.g., FETCH <cursorname> PRIOR INTO... Absolute position: first/last/absolute<nr> Limit effect of changes Performance: cursor FOR READ ONLY Concurrent access: INSENSITIVE CURSOR FOR 46 23

24 SQL in Programs: Cursor sensitivity Example: EXEC SQL DECLARE mycurs INSENSITIVE CURSOR FOR SELECT id,length,title FROM Movie FOR UPDATE ON length WHERE id >100; EXEC SQL OPEN... EXEC SQL FETCH mycurs INTO... UPDATE Movie SET lenght = length + 20 WHERE CURRENT OF mycurs; Changes not visible in result set Visible if cursor closed and reopened 47 SQL in Programs: Dynamic SQL Statements not known at compile time Statements computed by host language User input of query Tasks at run-time: Pass query string to SQL system Translate to executable statement Execute statement Use Prepared Statements 48 24

25 SQL in Programs: Dynamic SQL Step 1: EXEC SQL PREPARE <SQLvariable> FROM <string> String: SQL statement SQLvariable: assigned SQL statement Parse and prepare statement for execution Step 2: EXEC SQL EXECUTE <SQLvariable> Execute statement SQLvariable 49 SQL in Programs: Dynamic SQL Example: void readquery(){ EXEC SQL SQL BEGIN DECLARE SECTION; char *query; EXEC SQL SQL END END DECLARE SECTION; /* /* prompt user for for query allocate space make :query point to to query*/ EXEC SQL SQL PREPARE SQLquery FROM :query; EXEC SQL SQL EXECUTE SQLquery; } 50 25

26 SQL in Programs: Dynamic SQL Multiple execution: Prepare once Execute many times Single execution: Combination of step 1 an 2 EXEC SQL EXECUTE IMMEDIATE <string> Example: EXEC SQL SQL EXECUTE IMMEDIATE :query; 51 SQL in Programs: SQL & Java SQLJ Embedded SQL for Java Compiles to JDBC method call Defined and implemented by major DBS companies (Oracle in particular) JDBC Java call-level interface (API) for SQL DBS DB vendor independent Supports static and dynamic SQL Implemented by nearly all DB vendors 52 26

27 SQL in Programs: SQLJ Part 1: SQLJ Embedded SQL Mostly reviewed and implemented Integrated with JDBC API Oracle has placed Translator source into public domain Part 2: SQLJ Stored Procedures and UDFs Using Java static methods as SQL stored procedures & functions Leverages JDBC API Part 3: SQLJ Data Types Pure Java Classes as SQL ADTs Alternative to SQL:1999 Abstract Data Types 53 SQL in Programs: SQLJ Example // // Part of of a SQLJ program, one one method: public void changemovie(int movieid, int int newtape) { string mtitle; int int tnumber; #sql { SELECT m.title, count(t.id) INTO :mtitle, :tnumber FROM movie m, m, tape t WHERE m.id = :movieid AND AND m.id = t.movie_id }; }; if if (tnumber < 3) 3) #sql {INSERT INTO tape VALUES (:newtape, 'DVD', :movieid)}; } 54 27

28 SQL in Programs: SQL & Java Java in Web context (2 tier architecture): Java application Business Logic (application) JDBC Proprietary protocol of DBMS DBMS Database Server 55 SQL in Programs: SQL & Java Java in Web context (3 tier architecture): Java applet or WWW Browser GUI HTTP, RMI, CORBA, Application server Business Logic (application) JDBC DBMS Proprietary protocol of DBMS Database Server 56 28

29 SQL in Programs: JDBC 1. Preparation import java.sql.*; 2. Load a driver many vendor products Class.forName( "oracle.jdbc.driver.oracledriver"); String url = url JDBC-Driver and host information 57 SQL in Programs: JDBC 3. Set up connection database(s) Connection con = DriverManager.getConnection( "jdbc:oracle:thin:@<host>:<port>:<db>", <username>,<password>); Several connections at a time possible 4. Create statement object Statement stmt = con.createstatement(); Similar to channel for sending queries to database 58 29

30 SQL in Programs: JDBC 5. Send SQL query string ResultSet rs = stmt.executequery( <query>" ); results in ResultSet object 6. Process results one after the other processed with "hidden cursor" while (rs.next()){ for (i = 1; i <= numcols; i++){ if (i > 1) System.out.print(","); System.out.print(rs.getString(i)); } } 59 SQL in Programs: JDBC Example #import java.io.*; #import java.sql.*; #import java.util.*; Preparation 2. Load driver 3. Connect to database Class.forName("oracle.jdbc.driver.OracleDriver"); String url = "jdbc:oracle:thin:@kuh:1521:introkuh"; Protocol Sub-protocol Oracle-spec. Host Port Connection con = DriverManager.getConnection ( url, user", passwort"); 60 30

31 SQL in Programs: JDBC Example. 4. Create SQL-statement.. 5. execute statement. Statement stmt = con.createstatement(); ResultSet rs = stmt.executequery( "SELECT id, title FROM movie"); 6. Process results while (rs.next()) { String n = rs.getint( id"); String n = rs.getstring( title"); System.out.println(s + ": " + n); } } 61 SQL in Programs: JDBC variable binding No explicit cursor Several methods in JDBC e.g., boolean next(), void close(), <JavaType> get<javatype>(), boolean wasnull() Access result data by position or by name By position: By name: String s = rs.getstring(2); String rs.getstring ("b") ; 62 31

32 SQL in Programs: JDBC variable binding Example: java.sql.statement stmt = con.createstatement(); ResultSet rs1 rs1 = stmt.executequery ("SELECT id, id, title FROM movie"); while (rs1.next()) { int int mid mid = rs1.getint( id"); String mt mt = rs1.getstring( title"); System.out.println("ROW:" + mid mid + " " + mt);} ResultSet rs2 rs2 = stmt.executequery ("SELECT id, id, movie_id FROM tape"); while (rs2.next()) { int int tid tid = rs2.getint(1); int int tmid = rs2.getint(2); System.out.println("ROW:" + tid tid + " " + tmid);} 63 SQL in Programs: Prepared statements Pass input parameters Use prepared statement java.sql.preparedstatement prepstmt = con.preparestatement(<query>); Statement compiled Missing values in query:? Set value: prepstmt.setstring(<position>, <value>); 64 32

33 SQL in Programs: Prepared statements String mtitle;... java.sql.preparedstatement prepstmt = con.preparestatement( "SELECT count(*) FROM Movie m, m, Tape t WHERE t.movie_id = m.id AND AND m.title =? ); ); prepstmt.setstring(1, mtitle); ResultSet rs rs = prepstmt.executequery() ; while (rs.next()){ int int i = r.getint(1); // // by by position, no no name available System.out.println("Number of of tapes for for " + mtitle + " is: is: " +i) +i) } 65 SQL in Programs: Positioned update Positioned update needs cursor name Define cursor (JDBC 1) public void setcursorname(string name) throws SQLException Use for updates and deletes Define cursor (JDBC2) more flexible (anonymous) cursor handling setcursorname not implemented in Oracle Driver 66 33

34 SQL in Programs: Positioned update JDBC 2.0 Result set scrollable and updateable Example: Statement stmt = con.createstatement( ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); stmt.setfetchsize(25); ResultSet rs = stmt.executequery( "SELECT id, title FROM movie"); rs.first(); rs.updatestring( title, xxxxx ); rs.updaterow(); 67 SQL in Programs: Transactions Transaction: Collection of one or more database operations executed atomically (either all operations or none ) Programmers view: Everything between beginning of a sequence of operations on the database and COMMIT or ROLLBACK No explicit "transaction begin" command... OPEN MyCurs;... ; COMMIT; Begin of first transaction (first SQL command in program) End of first transaction 68 34

35 SQL in Programs: Transactions COMMIT Effects on database made permanent ROLLBACK Aborts transaction All changes in transaction undone (rolled back) Programmers View: Auto-commit mode: each SQL-command is a transaction Various transaction isolation levels 69 SQL in Programs: Transactions Transaction manager: Isolate concurrent users from each other Problems: Lost update: same object concurrently updated by two users, one update lost Dirty read: object value changed by transaction which aborts later Non-repeatable read: same object has different value within same transaction Phantom tuples: non-repeatable read caused by insertions or deletions 70 35

36 SQL in Programs: Isolation levels READ UNCOMMITTED SET TRANSACTION READ ONLY, ISOLATION LEVEL READ UNCOMMITTED Allows read access to uncommitted transactions Transaction has to be read only Lowest locking overhead Unpleasant effects may occur Example: TA1 increases the prices of some movies in DB by 5% TA2 scrolls through all movies, sees new prices 71 SQL in Programs: Isolation levels READ COMMITTED SET TRANSACTION ISOLATION LEVEL READ COMMITTED Allows read access to committed transactions only Long write locks, no or short read locks Non-repeatable reads Example: TA1 Read(a) x=x+a Read(a) y:=y-a TA2 Wrong balance Write a=a-10 commit 72 36

37 SQL in Programs: Isolation levels REPEATABLE READ SET TRANSACTION ISOLATION LEVEL REPEATABLE READ Allows read access to committed transactions only All data isolated from concurrent writes Read and write locks long term until end of TA Phantom tuples may occur 73 SQL in Programs: Isolation levels SERIALIZABLE SET TRANSACTION ISOLATION LEVEL SERIALIZABLE Allows read access to committed transactions only All data isolated from concurrent writes No phantom tuples inserted into the read set by other transaction Standard default 74 37

38 SQL in Programs: Transactions and JDBC Transactional properties of connections TRANSACTION_NONE (not implemented) TRANSACTION_READ_UNCOMMITTED TRANSACTION_READ_COMMITTED TRANSACTION_REPEATABLE_READ TRANSACTION_SERIALIZABLE Methods: public void settransactionisolation(int level) throws SQLExceptionpublic void setautocommit(boolean autocommit) public void commit() throws SQLException public void rollback() throws SQLException 75 SQL in Programs: Visibility of changes ResultSet rs = stmt1.executequery( "SELECT id, length FROM movie"); int i = stmt2.executeupdate ( DELETE FROM movie ); rs.first(); rs.updatestring( title, xxxxx ); rs.updaterow(); Scroll-insensitive result set no change by other result sets even in the same TA are visible Updates in result set r visible for operations on r Deletes / inserts (!) in result set r not visible Sensitive result set: depending on connection isolation level 76 38

39 SQL in Programs: Exception handling Abort transaction when error: EXEC SQL WHENEVER SQLERROR CONTINUE; EXEC SQL ROLLBACK WORK RELEASE; WHENEVER SQLERROR CONTINUE prevents ROLLBACK from (infinite) invocation of routine Example: void sql_error(msg){ char buf[500]; int int buflen, msglen; EXEC SQL SQL WHENEVER SQLERROR CONTINUE; EXEC SQL SQL ROLLBACK WORK RELEASE; buflen = sizeof (buf); sqlglm(buf, &buflen, &msglen); printf("%s\n", msg); printf("%*.s\n", msglen, buf); exit(1); } 77 SQL in Programs: Summary Access Rights Means to ensure data security ileges to roles Program DB communication: Fourth Generation Languages (4GL) Module Languages Call level interface Component architectures Transactions in programs Isolation levels Begin, end transaction 78 39

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

SQL Environment: Module Types. System Aspects of SQL. SQL Environment: Introduction. SQL Environment: Introduction. SQL Environment: Privileges SQL Environment: Module Types System Aspects of SQL Generic SQL Interface: Module: each query or statement Embedded SQL: SQL statements within host-language program SQL statements pre-processed to function

More information

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

Announcements. SQL: Part IV. Transactions. Summary of SQL features covered so far. Fine prints. SQL transactions. Reading assignments for this week Announcements 2 SQL: Part IV CPS 216 Advanced Database Systems Reading assignments for this week A Critique of ANSI SQL Isolation Levels, by Berenson et al. in SIGMOD 1995 Weaving Relations for Cache Performance,

More information

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

SQL: Programming Midterm in class next Thursday (October 5) Announcements (September 28) 2 Homework #1 graded Homework #2 due today Solution available this weekend SQL: Programming Midterm in class next Thursday (October 5) Open book, open notes Format similar

More information

JDBC, Transactions. Niklas Fors JDBC 1 / 38

JDBC, Transactions. Niklas Fors JDBC 1 / 38 JDBC, Transactions SQL in Programs Embedded SQL and Dynamic SQL JDBC Drivers, Connections, Statements, Prepared Statements Updates, Queries, Result Sets Transactions Niklas Fors (niklas.fors@cs.lth.se)

More information

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

SQL: Programming. Announcements (September 25) Motivation. CPS 116 Introduction to Database Systems. Pros and cons of SQL. SQL: Programming CPS 116 Introduction to Database Systems Announcements (September 25) 2 Homework #2 due this Thursday Submit to Yi not through Jun s office door Solution available this weekend No class

More information

Embedded SQL. Introduction

Embedded SQL. Introduction Embedded SQL Davood Rafiei 1 Introduction Basic Idea: Use SQL statements inside a host language (C, C++, Java, ). Advantages: Can do all the fancy things you do in C/C++/Java. Still have the power of SQL.

More information

Embedded SQL. Davood Rafiei

Embedded SQL. Davood Rafiei Embedded SQL Davood Rafiei 1 Introduction Basic Idea: Use SQL statements inside a host language (C, C++, Java, ). Advantages: Can do all the fancy things you do in C/C++/Java. Still have the power of SQL.

More information

Lecture 2. Introduction to JDBC

Lecture 2. Introduction to JDBC Lecture 2 Introduction to JDBC Introducing JDBC According to Sun, JDBC is not an acronym, but is commonly misinterpreted to mean Java DataBase Connectivity JDBC: is an API that provides universal data

More information

Databases 2012 Embedded SQL

Databases 2012 Embedded SQL Databases 2012 Christian S. Jensen Computer Science, Aarhus University SQL is rarely written as ad-hoc queries using the generic SQL interface The typical scenario: client server database SQL is embedded

More information

Database Application Development

Database Application Development Database Application Development Linda Wu (CMPT 354 2004-2) Topics SQL in application code Embedded SQL JDBC SQLJ Stored procedures Chapter 6 CMPT 354 2004-2 2 SQL in Application Code SQL commands can

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe Chapter 10 Outline Database Programming: Techniques and Issues Embedded SQL, Dynamic SQL, and SQLJ Database Programming with Function Calls: SQL/CLI and JDBC Database Stored Procedures and SQL/PSM Comparing

More information

Chapter 13 Introduction to SQL Programming Techniques

Chapter 13 Introduction to SQL Programming Techniques Chapter 13 Introduction to SQL Programming Techniques Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13 Outline Database Programming: Techniques and Issues Embedded

More information

Instructor: Jinze Liu. Fall 2008

Instructor: Jinze Liu. Fall 2008 Instructor: Jinze Liu Fall 2008 Database Project Database Architecture Database programming 2 Goal Design and implement a real application? Jinze Liu @ University of Kentucky 9/16/2008 3 Goal Design and

More information

SQL in a Server Environment

SQL in a Server Environment SQL in a Server Environment Vaidė Narváez Computer Information Systems January 13th, 2011 The Three-Tier Architecture Application logic components Copyright c 2009 Pearson Education, Inc. Publishing as

More information

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

Part I: Stored Procedures. Introduction to SQL Programming Techniques. CSC 375, Fall 2017 Introduction to SQL Programming Techniques CSC 375, Fall 2017 The Six Phases of a Project: Enthusiasm Disillusionment Panic Search for the Guilty Punishment of the Innocent Praise for non-participants

More information

Database Applications. SQL/PSM Embedded SQL JDBC

Database Applications. SQL/PSM Embedded SQL JDBC Database Applications SQL/PSM Embedded SQL JDBC 1 Course Objectives Design Construction Applications Usage 2 Course Objectives Interfacing When the course is through, you should Know how to connect to

More information

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

Calling SQL from a host language (Java and Python) Kathleen Durant CS 3200 Calling SQL from a host language (Java and Python) Kathleen Durant CS 3200 1 SQL code in other programming languages SQL commands can be called from within a host language (e.g., C++ or Java) program.

More information

JDBC Installation Transactions Metadata

JDBC Installation Transactions Metadata Course Name: Advanced Java Lecture 14 Topics to be covered JDBC Installation Transactions Metadata Steps in JDBC Connectivity:Connectivity:Here are the JDBC Steps to be followed while writing JDBC

More information

Non-interactive SQL. EECS Introduction to Database Management Systems

Non-interactive SQL. EECS Introduction to Database Management Systems Non-interactive SQL EECS3421 - Introduction to Database Management Systems Using a Database Interactive SQL: Statements typed in from terminal; DBMS outputs to screen. Interactive SQL is inadequate in

More information

CMPT 354 Database Systems I

CMPT 354 Database Systems I CMPT 354 Database Systems I Chapter 8 Database Application Programming Introduction Executing SQL queries: Interactive SQL interface uncommon. Application written in a host language with SQL abstraction

More information

How to program applications. CS 2550 / Spring 2006 Principles of Database Systems. SQL is not enough. Roadmap

How to program applications. CS 2550 / Spring 2006 Principles of Database Systems. SQL is not enough. Roadmap How to program applications CS 2550 / Spring 2006 Principles of Database Systems 05 SQL Programming Using existing languages: Embed SQL into Host language ESQL, SQLJ Use a library of functions Design a

More information

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

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 JDBC Stands for Java Database Connectivity, is an API specification that defines the following: 1. How to interact with database/data-source from Java applets, apps, servlets 2. How to use JDBC drivers

More information

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

ITCS Implementation. Jing Yang 2010 Fall. Class 14: Introduction to SQL Programming Techniques (Ch13) Outline ITCS 3160 Data Base Design and Implementation Jing Yang 2010 Fall Class 14: Introduction to SQL Programming Techniques (Ch13) Outline Database Programming: Techniques and Issues Three approaches: Embedded

More information

JDBC 3.0. Java Database Connectivity. 1 Java

JDBC 3.0. Java Database Connectivity. 1 Java JDBC 3.0 Database Connectivity 1 Contents 1 JDBC API 2 JDBC Architecture 3 Steps to code 4 Code 5 How to configure the DSN for ODBC Driver for MS-Access 6 Driver Types 7 JDBC-ODBC Bridge 8 Disadvantages

More information

UNIT III - JDBC Two Marks

UNIT III - JDBC Two Marks UNIT III - JDBC Two Marks 1.What is JDBC? JDBC stands for Java Database Connectivity, which is a standard Java API for databaseindependent connectivity between the Java programming language and a wide

More information

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

Wentworth Institute of Technology COMP570 Database Applications Fall 2014 Derbinsky. SQL Programming. Lecture 8. SQL Programming Lecture 8 1 Outline Context General Approaches Typical Programming Sequence Examples 2 Database Design and Implementation Process Normalization 3 SQL via API Embedded SQL SQLJ General Approaches DB Programming

More information

SQL: Transactions. Announcements (October 2) Transactions. CPS 116 Introduction to Database Systems. Project milestone #1 due in 1½ weeks

SQL: Transactions. Announcements (October 2) Transactions. CPS 116 Introduction to Database Systems. Project milestone #1 due in 1½ weeks SQL: Transactions CPS 116 Introduction to Database Systems Announcements (October 2) 2 Project milestone #1 due in 1½ weeks Come to my office hours if you want to chat about project ideas Midterm in class

More information

Transactions & Concurrency Control

Transactions & Concurrency Control CMPUT 391 Database Management Systems & Concurrency Control - - CMPUT 391 Database Management Systems Department of Computing Science University of Alberta Outline Transaction Isolation & Consistency Isolation

More information

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

ERwin and JDBC. Mar. 6, 2007 Myoung Ho Kim ERwin and JDBC Mar. 6, 2007 Myoung Ho Kim ERwin ERwin a popular commercial ER modeling tool» other tools: Dia (open source), Visio, ConceptDraw, etc. supports database schema generation 2 ERwin UI 3 Data

More information

Overview. Database Application Development. SQL in Application Code. SQL in Application Code (cont.)

Overview. Database Application Development. SQL in Application Code. SQL in Application Code (cont.) Overview Database Application Development Chapter 6 Concepts covered in this lecture: SQL in application code Embedded SQL Cursors Dynamic SQL JDBC SQLJ Stored procedures Database Management Systems 3ed

More information

Database Application Development

Database Application Development Database Application Development Chapter 6 Database Management Systems 3ed 1 Overview Concepts covered in this lecture: SQL in application code Embedded SQL Cursors Dynamic SQL JDBC SQLJ Stored procedures

More information

Database Application Development

Database Application Development Database Application Development Chapter 6 Database Management Systems 3ed 1 Overview Concepts covered in this lecture: SQL in application code Embedded SQL Cursors Dynamic SQL JDBC SQLJ Stored procedures

More information

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

Database Programming. Week 9. *Some of the slides in this lecture are created by Prof. Ian Horrocks from University of Oxford Database Programming Week 9 *Some of the slides in this lecture are created by Prof. Ian Horrocks from University of Oxford SQL in Real Programs We have seen only how SQL is used at the generic query interface

More information

Chapter 3 DB-Gateways

Chapter 3 DB-Gateways Prof. Dr.-Ing. Stefan Deßloch AG Heterogene Informationssysteme Geb. 36, Raum 329 Tel. 0631/205 3275 dessloch@informatik.uni-kl.de Chapter 3 DB-Gateways Outline Coupling DBMS and programming languages

More information

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

Introduction to JDBC. JDBC: Java Database Connectivity. Why Access a Database with Java? Compilation. Six Steps. Packages to Import Introduction to JDBC JDBC: Java Database Connectivity JDBC is used for accessing databases from Java applications Information is transferred from relations to objects and vice-versa databases optimized

More information

Unit 2 JDBC Programming

Unit 2 JDBC Programming Q1. What is JDBC? Explain the types of JDBC drivers? Ans. What is JDBC? JDBC is an API, which is used in java programming for interacting with database. JDBC (Java DataBase Connection) is the standard

More information

JDBC MOCK TEST JDBC MOCK TEST IV

JDBC MOCK TEST JDBC MOCK TEST IV http://www.tutorialspoint.com JDBC MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to JDBC Framework. You can download these sample mock tests at your

More information

Database connectivity (II)

Database connectivity (II) Lecture (07) Database connectivity (II) Dr. Ahmed ElShafee 1 Dr. Ahmed ElShafee, ACU Spring 2011, Distributed Systems Agenda Connecting DB 2 Dr. Ahmed ElShafee, ACU Spring 2011, Distributed Systems The

More information

Chapter 3 DB-Gateways

Chapter 3 DB-Gateways Prof. Dr.-Ing. Stefan Deßloch AG Heterogene Informationssysteme Geb. 36, Raum 329 Tel. 0631/205 3275 dessloch@informatik.uni-kl.de Chapter 3 DB-Gateways Outline Coupling DBMS and programming languages

More information

Database Application Development

Database Application Development CS 461: Database Systems Database Application Development supplementary material: Database Management Systems Sec. 6.2, 6.3 DBUtils.java, Student.java, Registrar.java, RegistrarServlet.java, PgRegistrar.sql

More information

Locking, concurrency, and isolation

Locking, concurrency, and isolation Holdable result sets and autocommit When autocommit is on, a positioned update or delete statement will automatically cause the transaction to commit. If the result set has holdability ResultSet.CLOSE_CURSORS_AT_COMMIT,

More information

CSCC43H: Introduction to Databases. Lecture 9

CSCC43H: Introduction to Databases. Lecture 9 CSCC43H: Introduction to Databases Lecture 9 Wael Aboulsaadat Acknowledgment: these slides are partially based on Prof. Garcia-Molina & Prof. Ullman slides accompanying the course s textbook. CSCC43: Introduction

More information

SNS COLLEGE OF ENGINEERING, Coimbatore

SNS COLLEGE OF ENGINEERING, Coimbatore SNS COLLEGE OF ENGINEERING, Coimbatore 641 107 Accredited by NAAC UGC with A Grade Approved by AICTE and Affiliated to Anna University, Chennai IT6503 WEB PROGRAMMING UNIT 03 JDBC JDBC Overview JDBC implementation

More information

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

Database Programming Overview. COSC 304 Introduction to Database Systems. Database Programming. JDBC Interfaces. JDBC Overview COSC 304 Introduction to Database Systems Database Programming Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Database Programming Overview Most user interaction with

More information

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

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 Agenda Lecture (07) Database connectivity (II) Connecting DB Dr. Ahmed ElShafee 1 Dr. Ahmed ElShafee, ACU Spring 2011, Distributed Systems 2 Dr. Ahmed ElShafee, ACU Spring 2011, Distributed Systems The

More information

INTRODUCTION TO JDBC - Revised spring

INTRODUCTION TO JDBC - Revised spring INTRODUCTION TO JDBC - Revised spring 2004 - 1 What is JDBC? Java Database Connectivity (JDBC) is a package in the Java programming language and consists of several Java classes that deal with database

More information

Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 10: Transaction processing. November 14, Lecturer: Rasmus Pagh

Introduction to Databases, Fall 2005 IT University of Copenhagen. Lecture 10: Transaction processing. November 14, Lecturer: Rasmus Pagh Introduction to Databases, Fall 2005 IT University of Copenhagen Lecture 10: Transaction processing November 14, 2005 Lecturer: Rasmus Pagh Today s lecture Part I: Transaction processing Serializability

More information

Java Database Connectivity

Java Database Connectivity Java Database Connectivity ADVANCED FEATURES Dr. Syed Imtiyaz Hassan Assistant Professor, Deptt. of CSE, Jamia Hamdard (Deemed to be University), New Delhi, India. s.imtiyaz@jamiahamdard.ac.in Agenda Scrollable

More information

Database Application Programs PL/SQL, Java and the Web

Database Application Programs PL/SQL, Java and the Web Database Application Programs PL/SQL, Java and the Web As well as setting up the database and running queries, it is vital to be able to build programs which manage the database although they will only

More information

INTRODUCTION TO JDBC - Revised Spring

INTRODUCTION TO JDBC - Revised Spring INTRODUCTION TO JDBC - Revised Spring 2006 - 1 What is JDBC? Java Database Connectivity (JDBC) is an Application Programmers Interface (API) that defines how a Java program can connect and exchange data

More information

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

Java and the Java DataBase Connectivity (JDBC) API. Todd Kaufman April 25, 2002 Java and the Java DataBase Connectivity (JDBC) API Todd Kaufman April 25, 2002 Agenda BIO Java JDBC References Q&A Speaker 4 years Java experience 4 years JDBC experience 3 years J2EE experience BS from

More information

Database Applications

Database Applications Database Applications Database Programming Application Architecture Objects and Relational Databases John Edgar 2 Users do not usually interact directly with a database via the DBMS The DBMS provides

More information

JDBC - INTERVIEW QUESTIONS

JDBC - INTERVIEW QUESTIONS JDBC - INTERVIEW QUESTIONS http://www.tutorialspoint.com/jdbc/jdbc_interview_questions.htm Copyright tutorialspoint.com Dear readers, these JDBC Interview Questions have been designed specially to get

More information

General Overview - rel. model. Carnegie Mellon Univ. Dept. of Computer Science Database Applications. Reminder: our Mini-U db

General Overview - rel. model. Carnegie Mellon Univ. Dept. of Computer Science Database Applications. Reminder: our Mini-U db Faloutsos 15-415 Carnegie Mellon Univ. Dept. of Computer Science 15-415 - Database Applications Lecture#8 (cont d): SQL, Part 2 General Overview - rel. model Formal query languages rel algebra and calculi

More information

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

Database in Applica.on Development. Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata Database in Applica.on Deelopment Debapriyo Majumdar DBMS Fall 2016 Indian Statistical Institute Kolkata SQL from Programs SQL commands can be called from within a host language program C, C++, Jaa, Two

More information

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

Lecture 27 10/30/15. CMPSC431W: Database Management Systems. Instructor: Yu- San Lin CMPSC431W: Database Management Systems Lecture 27 10/30/15 Instructor: Yu- San Lin yusan@psu.edu Course Website: hcp://www.cse.psu.edu/~yul189/cmpsc431w Slides based on McGraw- Hill & Dr. Wang- Chien Lee

More information

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

Cyrus Shahabi Computer Science Department University of Southern California C. Shahabi Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California shahabi@usc.edu 1 Overview JDBC Package Connecting to databases with JDBC Executing

More information

Application Programming for Relational Databases

Application Programming for Relational Databases Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California shahabi@usc.edu 1 Overview JDBC Package Connecting to databases with JDBC Executing

More information

JDBC Drivers Type. JDBC drivers implement the defined interfaces in the JDBC API for interacting with your database server.

JDBC Drivers Type. JDBC drivers implement the defined interfaces in the JDBC API for interacting with your database server. JDBC Drivers Type 1 What is JDBC Driver? JDBC drivers implement the defined interfaces in the JDBC API for interacting with your database server. For example, using JDBC drivers enable you to open database

More information

JDBC Programming: Intro

JDBC Programming: Intro JDBC Programming: Intro Most interaction with DB is not via interactive interface Most people interact via 1. Application programs directly 2. Apps over the internet There are 3 general approaches to developing

More information

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

BUSINESS INTELLIGENCE LABORATORY. Data Access: Relational Data Bases. Business Informatics Degree BUSINESS INTELLIGENCE LABORATORY Data Access: Relational Data Bases Business Informatics Degree RDBMS data access 2 Protocols and API ODBC, OLE DB, ADO, ADO.NET, JDBC JDBC Programming Java classes java.sql

More information

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

Kyle Brown Knowledge Systems Corporation by Kyle Brown and Knowledge Systems Corporation Kyle Brown Knowledge Systems Corporation 1 What is the JDBC? What other persistence mechanisms are available? What facilities does it offer? How is it used? 2 JDBC is the Java DataBase Connectivity specification

More information

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

Types of Databases. Types of Databases. Types of Databases. Databases and Web. Databases and Web. Relational databases may also have indexes Types of Databases Relational databases contain stuctured data tables, columns, fixed datatype for each column Text databases are available for storing non-structured data typically text databases store

More information

Questions and Answers. A. A DataSource is the basic service for managing a set of JDBC drivers.

Questions and Answers. A. A DataSource is the basic service for managing a set of JDBC drivers. Q.1) What is, in terms of JDBC, a DataSource? A. A DataSource is the basic service for managing a set of JDBC drivers B. A DataSource is the Java representation of a physical data source C. A DataSource

More information

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

JDBC drivers are divided into four types or levels. The different types of jdbc drivers are: How many types of JDBC Drivers are present and what are they? JDBC drivers are divided into four types or levels. The different types of jdbc drivers are: Type 1: JDBC-ODBC Bridge driver (Bridge) Type

More information

CMPUT 391 Database Management Systems. JDBC in Review. - Lab 2 -

CMPUT 391 Database Management Systems. JDBC in Review. - Lab 2 - CMPUT 391 Database Management Systems JDBC in Review - - Department of Computing Science University of Alberta What Is JDBC? JDBC is a programming interface JDBC allows developers using java to gain access

More information

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

JDBC Architecture. JDBC API: This provides the application-to- JDBC Manager connection. JDBC PROGRAMMING JDBC JDBC Java DataBase Connectivity Useful for database driven applications Standard API for accessing relational databases Compatible with wide range of databases Current Version JDBC

More information

Chapter 9 SQL in a server environment

Chapter 9 SQL in a server environment Chapter 9 SQL in a server environment SQL in a Programming Environment embedded SQL persistent stored modules Database-Connection Libraries Call-level interface (CLI) JDBC PHP SQL in Real Programs We have

More information

DATABASE DESIGN I - 1DL300

DATABASE DESIGN I - 1DL300 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

More information

Accessing databases in Java using JDBC

Accessing databases in Java using JDBC Accessing databases in Java using JDBC Introduction JDBC is an API for Java that allows working with relational databases. JDBC offers the possibility to use SQL statements for DDL and DML statements.

More information

COSC 304 Introduction to Database Systems. Advanced SQL. Dr. Ramon Lawrence University of British Columbia Okanagan

COSC 304 Introduction to Database Systems. Advanced SQL. Dr. Ramon Lawrence University of British Columbia Okanagan COSC 304 Introduction to Database Systems Advanced SQL Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Transaction Management Overview The database system must ensure that

More information

Java Database Connectivity

Java Database Connectivity Java Database Connectivity INTRODUCTION Dr. Syed Imtiyaz Hassan Assistant Professor, Deptt. of CSE, Jamia Hamdard (Deemed to be University), New Delhi, India. s.imtiyaz@jamiahamdard.ac.in Agenda Introduction

More information

Logging and Recovery. 444 Section, April 23, 2009

Logging and Recovery. 444 Section, April 23, 2009 Logging and Recovery 444 Section, April 23, 2009 Reminders Project 2 out: Due Wednesday, Nov. 4, 2009 Homework 1: Due Wednesday, Oct. 28, 2009 Outline Project 2: JDBC ACID: Recovery Undo, Redo logging

More information

JDBC BASIC 19/05/2012. Objectives. Java Database Connectivity. Definitions of JDBC. Part 1. JDBC basic Working with JDBC Adv anced JDBC programming

JDBC BASIC 19/05/2012. Objectives. Java Database Connectivity. Definitions of JDBC. Part 1. JDBC basic Working with JDBC Adv anced JDBC programming Objectives Java Database Connectivity JDBC basic Working with JDBC Adv anced JDBC programming By Võ Văn Hải Faculty of Information Technologies Summer 2012 2/27 Definitions of JDBC JDBC APIs, which provides

More information

Top 50 JDBC Interview Questions and Answers

Top 50 JDBC Interview Questions and Answers Top 50 JDBC Interview Questions and Answers 1) What is the JDBC? JDBC stands for Java Database Connectivity. JDBC is a Java API that communicates with the database and execute SQLquery. 2) What is a JDBC

More information

IBM -

IBM - 6.1 6.2 6.3 6.4 2 6.1 q 6.1.1 SQL 3 q 6.1.2 Ø q Ø Ø Ø call level interface q Ø Web 4 6.1 6.2 6.3 6.4 5 6.2 q 6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 SQL 6 6.2.1 q q Ø Ø Ø Ø 7 6.2.2 q q CONNECT TO < > < > < > [AS

More information

Introduction to SQL & Database Application Development Using Java

Introduction to SQL & Database Application Development Using Java Introduction to SQL & Database Application Development Using Java By Alan Andrea The purpose of this paper is to give an introduction to relational database design and sql with a follow up on how these

More information

Transaction Management: Introduction (Chap. 16)

Transaction Management: Introduction (Chap. 16) Transaction Management: Introduction (Chap. 16) CS634 Class 14 Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke What are Transactions? So far, we looked at individual queries;

More information

Transactions. Juliana Freire. Some slides adapted from L. Delcambre, R. Ramakrishnan, G. Lindstrom, J. Ullman and Silberschatz, Korth and Sudarshan

Transactions. Juliana Freire. Some slides adapted from L. Delcambre, R. Ramakrishnan, G. Lindstrom, J. Ullman and Silberschatz, Korth and Sudarshan Transactions Juliana Freire Some slides adapted from L. Delcambre, R. Ramakrishnan, G. Lindstrom, J. Ullman and Silberschatz, Korth and Sudarshan Motivation Database systems are normally being accessed

More information

Database Application Development

Database Application Development CS 500: Fundamentals of Databases Database Application Development supplementary material: Database Management Systems Sec. 6.2, 6.3 DBUtils.java, Student.java, Registrar.java, RegistrarServlet.java, PgRegistrar.sql

More information

Database Applications (15-415)

Database Applications (15-415) Database Applications (15-415) SQL-Part III & Storing Data: Disks and Files- Part I Lecture 8, February 5, 2014 Mohammad Hammoud Today Last Session: Standard Query Language (SQL)- Part II Today s Session:

More information

SQLJ: Java and Relational Databases

SQLJ: Java and Relational Databases SQLJ: Java and Relational Databases Phil Shaw, Sybase Inc. Brian Becker, Oracle Corp. Johannes Klein, Tandem/Compaq Mark Hapner, JavaSoft Gray Clossman, Oracle Corp. Richard Pledereder, Sybase Inc. Agenda

More information

Example: Transfer Euro 50 from A to B

Example: Transfer Euro 50 from A to B TRANSACTIONS Example: Transfer Euro 50 from A to B 1. Read balance of A from DB into Variable a: read(a,a); 2. Subtract 50.- Euro from the balance: a:= a 50; 3. Write new balance back into DB: write(a,a);

More information

Database Application Development

Database Application Development Database Application Development Chapter 6 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Overview Concepts covered in this lecture: SQL in application code Embedded SQL Cursors Dynamic

More information

Programming in Java

Programming in Java 320341 Programming in Java Fall Semester 2014 Lecture 16: Introduction to Database Programming Instructor: Slides: Jürgen Schönwälder Bendick Mahleko Objectives This lecture introduces the following -

More information

数据库系统概论讲义, 第 8 章编程 SQL,2015,3

数据库系统概论讲义, 第 8 章编程 SQL,2015,3 数据库系统概论 An Introduction to Database Systems 第八章数据库编程 (ODBC, PL/SQL) 2016, 3, 29 Programmatic SQL Three types of programmatic SQL Embedded SQL statements ISO standard specifies embedded support for C, COBOL,

More information

What are Transactions? Transaction Management: Introduction (Chap. 16) Major Example: the web app. Concurrent Execution. Web app in execution (CS636)

What are Transactions? Transaction Management: Introduction (Chap. 16) Major Example: the web app. Concurrent Execution. Web app in execution (CS636) What are Transactions? Transaction Management: Introduction (Chap. 16) CS634 Class 14, Mar. 23, 2016 So far, we looked at individual queries; in practice, a task consists of a sequence of actions E.g.,

More information

SQL: Transactions. Introduction to Databases CompSci 316 Fall 2017

SQL: Transactions. Introduction to Databases CompSci 316 Fall 2017 SQL: Transactions Introduction to Databases CompSci 316 Fall 2017 2 Announcements (Tue., Oct. 17) Midterm graded Sample solution already posted on Sakai Project Milestone #1 feedback by email this weekend

More information

SQL STORED ROUTINES. CS121: Relational Databases Fall 2017 Lecture 9

SQL STORED ROUTINES. CS121: Relational Databases Fall 2017 Lecture 9 SQL STORED ROUTINES CS121: Relational Databases Fall 2017 Lecture 9 SQL Functions 2 SQL queries can use sophisticated math operations and functions Can compute simple functions, aggregates Can compute

More information

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

The Design of JDBC The Structured Query Language Basic JDBC Programming Concepts Query Execution Scrollable and Updatable Result Sets Course Name: Advanced Java Lecture 13 Topics to be covered The Design of JDBC The Structured Query Language Basic JDBC Programming Concepts Query Execution Scrollable and Updatable Result Sets Introducing

More information

Chapter 4 Application Programs and Object-Relational Capabilities

Chapter 4 Application Programs and Object-Relational Capabilities Chapter 4 Application Programs and Object-Relational Capabilities Recent Development for Data Models 2016 Stefan Deßloch The "Big Picture" SQL99 Client DB Server Server-side Logic dynamic SQL JDBC 2.0

More information

Efficient Object-Relational Mapping for JAVA and J2EE Applications or the impact of J2EE on RDB. Marc Stampfli Oracle Software (Switzerland) Ltd.

Efficient Object-Relational Mapping for JAVA and J2EE Applications or the impact of J2EE on RDB. Marc Stampfli Oracle Software (Switzerland) Ltd. Efficient Object-Relational Mapping for JAVA and J2EE Applications or the impact of J2EE on RDB Marc Stampfli Oracle Software (Switzerland) Ltd. Underestimation According to customers about 20-50% percent

More information

JDBC [Java DataBase Connectivity]

JDBC [Java DataBase Connectivity] JDBC [Java DataBase Connectivity] Introduction Almost all the web applications need to work with the data stored in the databases. JDBC is Java specification that allows the Java programs to access the

More information

Chapter 3 DB-Gateways

Chapter 3 DB-Gateways Prof. Dr.-Ing. Stefan Deßloch AG Heterogene Informationssysteme Geb. 36, Raum 329 Tel. 0631/205 3275 dessloch@informatik.uni-kl.de Chapter 3 DB-Gateways Outline Coupling DBMS and programming languages

More information

SQL DML and DB Applications, JDBC

SQL DML and DB Applications, JDBC SQL DML and DB Applications, JDBC Week 4.2 Week 4 MIE253-Consens 1 Schedule Week Date Lecture Topic 1 Jan 9 Introduction to Data Management 2 Jan 16 The Relational Model 3 Jan. 23 Constraints and SQL DDL

More information

EMBEDDED SQL. SE 3DB3 Fall 2016 MICHAEL LIUT DEPARTMENT OF COMPUTING AND SOFTWARE MCMASTER UNIVERSITY

EMBEDDED SQL. SE 3DB3 Fall 2016 MICHAEL LIUT DEPARTMENT OF COMPUTING AND SOFTWARE MCMASTER UNIVERSITY EMBEDDED SQL MICHAEL LIUT (LIUTM@MCMASTER.CA) DEPARTMENT OF COMPUTING AND SOFTWARE MCMASTER UNIVERSITY SE 3DB3 Fall 2016 (Slides adapted from Dr. Fei Chiang, Diane Horton, examples from J. Ullman, J. Widom)

More information

Oracle Database 10g Java Web

Oracle Database 10g Java Web Oracle Database 10g Java Web 2005 5 Oracle Database 10g Java Web... 3... 3... 4... 4... 4 JDBC... 5... 5... 5 JDBC... 6 JDBC... 8 JDBC... 9 JDBC... 10 Java... 11... 12... 12... 13 Oracle Database EJB RMI/IIOP...

More information

Visit for more.

Visit  for more. Chapter 6: Database Connectivity Informatics Practices Class XII (CBSE Board) Revised as per CBSE Curriculum 2015 Visit www.ip4you.blogspot.com for more. Authored By:- Rajesh Kumar Mishra, PGT (Comp.Sc.)

More information

Oracle Exam 1z0-809 Java SE 8 Programmer II Version: 6.0 [ Total Questions: 128 ]

Oracle Exam 1z0-809 Java SE 8 Programmer II Version: 6.0 [ Total Questions: 128 ] s@lm@n Oracle Exam 1z0-809 Java SE 8 Programmer II Version: 6.0 [ Total Questions: 128 ] Oracle 1z0-809 : Practice Test Question No : 1 Given: public final class IceCream { public void prepare() { public

More information

Self-test Database application programming with JDBC

Self-test Database application programming with JDBC Self-test Database application programming with JDBC Document: e1216test.fm 16 January 2018 ABIS Training & Consulting Diestsevest 32 / 4b B-3000 Leuven Belgium TRAINING & CONSULTING INTRODUCTION TO THE

More information