Web Technologies IT230 Dr Mohamed Habib.

Slides:



Advertisements
Similar presentations
CE203 - Application Programming Autumn 2013CE203 Part 51 Part 5.
Advertisements

Embedded SQL John Ortiz. Lecture 15Embedded SQL2 Why Isn’t Interactive SQL Enough?  How to do this using interactive SQL?  Print a well-formatted transcript.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13 Introduction to SQL Programming Techniques.
Distributed Application Development B. Ramamurthy.
Fundamentals, Design, and Implementation, 9/e Chapter 14 JDBC, Java Server Pages, and MySQL.
1 JDBC Java Database Connectivity. 2 c.pdf
Integration case study Week 8 – Lecture 1. Enrolment request (Workstation) Application server Database server Database New University Student Record System.
JDBC. In This Class We Will Cover: What SQL is What ODBC is What JDBC is JDBC basics Introduction to advanced JDBC topics.
JDBC / ODBC JDBC is the java API that facilitate interaction of a java application with the DBMS. FIRST APPROACH:
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.
Accessing Databases with JDBC. Introduction to JDBC JDBC provides a standard library for accessing databases by using the JDBC API. JDBC standardizes.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 David M. Kroenke’s Chapter Seven: SQL for Database Construction and.
CS178 Database Management “JDBC”. What is JDBC ? JDBC stands for “Java DataBase Connectivity” The standard interface for communication between a Java.
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.
Announcements Read JDBC Project Step 5, due Monday.
M1G Introduction to Database Development 6. Building Applications.
Chapter 7 Advanced SQL Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
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,
CONTROLPANEL Java.sql package This package provides the APIs for accessing and processing data which is stored in the database especially relational.
Connecting to Oracle using Java November 4, 2009 David Goldschmidt, Ph.D. David Goldschmidt, Ph.D.
 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.
Stored procedures1 Stored procedures and functions Procedures and functions stored in the database.
JDBC. Preliminaries Database Database Collection of data Collection of data DBMS DBMS Database management system Database management system Stores and.
JDBC – Java Database Concentricity
Copyright  Oracle Corporation, All rights reserved. 6 Accessing a Database Using the JDBC API.
8 1 Chapter 8 Advanced SQL Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 8 Advanced SQL.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Java Database Connectivity. Java and the database Database is used to store data. It is also known as persistent storage as the data is stored and can.
Copyright © 2002 ProsoftTraining. All rights reserved. Building Database Client Applications Using JDBC 2.0.
Chapter 17 Accessing Databases with JDBC. JDBC JDBC provides a standard library for accessing relational databases. By using the JDBC API, you can access.
JDBC Database Programming in Java Prepared by., Mrs.S.Amudha AP/SWE.
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 CHAPTER-2. JDBC - Java Database Connectivity. JDBC from Sun Microsystems provides API or Protocol to interact with different databases. With the.
Li Tak Sing COMPS311F. Database programming JDBC (Java Database Connectivity) Java version of ODBC (Open Database Connectivity) ODBC provides a standard.
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.
Database Access Using JDBC BCIS 3680 Enterprise Programming.
DAT602 Database Application Development Lecture 8 Advanced JDBC.
Access Databases from Java Programs via JDBC Tessema M. Mengistu Department of Computer Science Southern Illinois University Carbondale
Learningcomputer.com SQL Server 2008 –Views, Functions and Stored Procedures.
Basics of JDBC Session 14.
A Guide to SQL, Eighth Edition Chapter Six Updating Data.
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
1 JDBC – Java Database Connectivity CS , Spring 2010.
CS 440 Database Management Systems Stored procedures & OR mapping 1.
Chapter 7 Chapter 7 Java Database Connectivity using JSP 1 (IS 203) WebProgramming (IS 203) Web Programming.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
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.
7.5 Using Stored-Procedure and Triggers NAME MATRIC NUM GROUP Muhammad Azwan Bin Khairul Anwar CS2305A Muhammad Faiz Bin Badrol Shah CS2305B.
© 2007 by Prentice Hall (Hoffer, Prescott & McFadden) 1 Advanced SQL.
DEPTT. OF COMP. SC & APPLICATIONS
Interacting with Database
Running a Forms Developer Application
ODBC, OCCI and JDBC overview
JDBC Database Management Database connectivity
JDBC – Java Database Connectivity
A very brief introduction
PL/SQL Scripting in Oracle:
Introduction to Server-Side Web Development using JSP and Databases
Mr. Harish Sharma Asst. Professor Dept. of CA & IT SGRRITS Dehradun
Interacting with Database
Database Processing: David M. Kroenke’s Chapter Seven:
MSIS 655 Advanced Business Applications Programming
Java Database Connectivity
Chapter 8 Advanced SQL.
JAVA DATABaSE CONNECTIVITY
Presentation transcript:

Web Technologies IT230 Dr Mohamed Habib

Objectives Implement a database in Java. Implement database access with JDBC. Use a connector to persist objects in a relational database

JDBC JDBC provides a standard library for accessing relational databases. By using the JDBC API, you can access a wide variety of SQL databases with exactly the same Java syntax. It is important to note that although the JDBC API standardizes the approach for: - connecting to databases the syntax for sending queries committing transactions the data structure representing the result JDBC does not attempt to standardize the SQL syntax. So, you can use any SQL extensions your database vendor supports. However, since most queries follow standard SQL syntax, using JDBC lets you change database hosts, ports, and even database vendors with minimal changes to your code.

Seven Steps for Database Access JDBC Seven Steps for Database Access Load the JDBC driver Define the connection URL Establish the connection Create a Statement object Execute a query or update Process the result set Close the statement and connection

JDBC

Define the Connection URL

Establish the Connection

Get MetaData

Create a Statement Object

Execute a Query or Update

Process the Results

Process the Results

Process the Results

Close the Connection

Using Prepared Statements

Adv. Of Prepared Statements Be cautious though: a prepared statement does not always execute faster than an ordinary SQL statement. The performance improvement can depend on the particular SQL command you are executing. For a more detailed analysis of the performance for prepared statements in Oracle. However, performance is not the only advantage of a prepared statement. Security is another advantage. We recommend that you always use a prepared statement or stored procedure to update database values when accepting input from a user through an HTML form. This approach is strongly recommended over the approach of building an SQL statement by concatenating strings from the user input values.

Adv. Of Prepared Statements

Creating Callable Statements With a CallableStatement, you can execute a stored procedure or function in a database. For example, in an Oracle database, you can write a procedure or function in PL/SQL and store it in the database along with the tables. Then, you can create a connection to the database and execute the stored procedure or function through a CallableStatement.

Adv. Of Callable Statements A stored procedure has many advantages. For instance, syntax errors are caught at compile time instead of at runtime; the database procedure may run much faster than a regular SQL query; and the programmer only needs to know about the input and output parameters, not the table structure. In addition, coding of the stored procedure may be simpler in the database language than in the Java programming language because access to native database capabilities (sequences, triggers, multiple cursors) is possible.

DisAdv. Of Callable Statements One disadvantage of a stored procedure is that you may need to learn a new database-specific language (note, however, that Oracle8i Database and later support stored procedures written in the Java programming language). A second disadvantage is that the business logic of the stored procedure executes on the database server instead of on the client machine or Web server.

Creating Callable Statements

Using Database Transactions When a database is updated, by default the changes are permanently written (or committed) to the database. However, this default behavior can be programmatically turned off. If autocommitting is turned off and a problem occurs with the updates, then each change to the database can be backed out (or rolled back to the original values). If the updates execute successfully, then the changes can later be permanently committed to the database. This approach is known as transaction management.

Using Database Transactions The default for a database connection is autocommit; that is, each executed statement is automatically committed to the database. Thus, for transaction management you first need to turn off autocommit for the connection by calling setAutoCommit(false) .

Using Database Transactions

Using Database Transactions Here, the statement for obtaining a connection from the DriverManager is outside the try/catch block. That way, rollback is not called unless a connection is successfully obtained. However, the getConnection method can still throw an SQLException and must be thrown by the enclosing method or be caught in a separate try/catch block.

Chapter 18 CONFIGURING MS ACCESS, MYSQL, AND ORACLE9I Only for practical work

IT230 – Week 11 Thanks,