Chapter 121 Adding Power to Database Access with JSP JavaServer Pages By Xue Bai.

Slides:



Advertisements
Similar presentations
1 Chapter 10 Protecting Data Integrity in a Multiuser Environment.
Advertisements

Automating Tasks With Macros
Introduction to Structured Query Language (SQL)
TRANSACTIONS. Definition One or more SQL statements that operate as a single unit. Each statement in the unit is completely interdependent. If one statement.
JDBC. In This Class We Will Cover: What SQL is What ODBC is What JDBC is JDBC basics Introduction to advanced JDBC topics.
Introduction to Structured Query Language (SQL)
1 Chapter 2 Reviewing Tables and Queries. 2 Chapter Objectives Identify the steps required to develop an Access application Specify the characteristics.
Managing Concurrency in Web Applications. DBI 2007 HUJI-CS 2 Intersection of Concurrent Accesses A fundamental property of Web sites: Concurrent accesses.
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
© Wang Bin 2004 JDBC ----Java Database Connectivity.
Java Database Connectivity (JDBC) Introduction to JDBC JDBC is a simple API for connecting from Java applications to multiple databases. Lets you smoothly.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
Introduction to Databases Chapter 7: Data Access and Manipulation.
Web Design & Development 1 Lec Web Design & Development 2 More on JDBC.
Databases: Queries with Java Dr Andy Evans. JDBC SQL Three methods: Statements: Standard, simple, SQL. PreparedStatements: Compiled SQL statements that.
JDBC Tutorial MIE456 - Information Systems Infrastructure II Vinod Muthusamy November 4, 2004.
SQL/Lesson 4/Slide 1 of 45 Using Subqueries and Managing Databases Objectives In this lesson, you will learn to: *Use subqueries * Use subqueries with.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
1cs Intersection of Concurrent Accesses A fundamental property of Web sites: Concurrent accesses by multiple users Concurrent accesses intersect.
DATABASE TRANSACTION. Transaction It is a logical unit of work that must succeed or fail in its entirety. A transaction is an atomic operation which may.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
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.
Chapter 25 Databases. Chapter Scope Database concepts Tables and queries SQL statements Managing data in a database Java Foundations, 3rd Edition, Lewis/DePasquale/Chase25.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
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.
Topic 1: Introduction to SQL. SQL stands for Structured Query Language. SQL is a standard computer language for accessing and manipulating databases SQL.
1 Database Systems Introduction to Microsoft Access Part 2.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Copyright © 2002 ProsoftTraining. All rights reserved. Building Database Client Applications Using JDBC 2.0.
JSTL The JavaServer Pages Standard Tag Library (JSTL) is a collection of useful JSP tags which encapsulates core functionality common to many JSP applications.
Lab_03: Basic SQL.
1 DBS201: More on SQL Lecture 3. 2 Agenda How to use SQL to update table definitions How to update data in a table How to join tables together.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CHAPTER 17 Databases.
(SQL - Structured Query Language)
Web Programming MySql JDBC Web Programming.
1 Intro stored procedures Declaring parameters Using in a sproc Intro to transactions Concurrency control & recovery States of transactions Desirable.
JDBC™ Advanced Concepts
JDBC Part II CS 124. More about JDBC Types Statement versus PreparedStatement Timeout NULL values Meta-data close() methods Exceptions Transactions JDBC.
A Guide to SQL, Eighth Edition Chapter Six Updating Data.
©Bob Godfrey, 2002, 2005 Lecture 17: Transaction Integrity and Concurrency BSA206 Database Management Systems.
10 1 Chapter 10 - A Transaction Management Database Systems: Design, Implementation, and Management, Rob and Coronel.
Using Oracle JDBC How to Run JDBC on Your Account Communication Mechanism Using Metadata Building a Database Auto Commit v.s Atomic Transaction.
JSP/Database Connectivity Instructor: Dr. M. Anwar Hossain.
MySQL Tutorial. Databases A database is a container that groups together a series of tables within a single structure Each database can contain 1 or more.
Chapter 7 Chapter 7 Java Database Connectivity using JSP 1 (IS 203) WebProgramming (IS 203) Web Programming.
JDBC.
Lec-7. The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE.
JDBC IV IS Outline  Batch processing  Transactions  Homework #2  Examples.
CHAPTER 7 LESSON B Creating Database Reports. Lesson B Objectives  Describe the components of a report  Modify report components  Modify the format.
IFS180 Intro. to Data Management Chapter 10 - Unions.
Transactions. Contents ● Transactions ● Save Points ● Batch Updates.
Concurrency Control A database must provide a mechanism that will ensure that all possible schedules are either conflict or view serializable, and are.
CS3220 Web and Internet Programming Database Access with JDBC
Chapter 5 Introduction to SQL.
SQL and SQL*Plus Interaction
Metadata.
Chapter Topics Chapter 16 discusses the following main topics:
UNIT-2 Java Database Programming
On transactions, and Atomic Operations
Chapter # 7 Introduction to Structured Query Language (SQL) Part II.
Transactions, Locking and Query Optimisation
On transactions, and Atomic Operations
HAVING,INDEX,COMMIT & ROLLBACK
Data Access Layer (Con’t) (Overview)
Objectives In this lesson, you will learn to:
Objectives In this lesson, you will learn about:
Presentation transcript:

Chapter 121 Adding Power to Database Access with JSP JavaServer Pages By Xue Bai

Chapter 122 Objectives In this chapter, you will: Create more powerful query statements using the IN and BETWEEN Access database metadata from a JSP page Control transactions to ensure database integrity Create and use beans to access a database

Chapter 123 The IN Operator The IN operator is used to determine whether a field’s value falls within a specified range of values The use of the IN operator takes the following form: SELECT column_list FROM table_name WHERE a_column_name IN (value1, value2, …)

Chapter 124 The IN Operator The series values listed within the IN operator can be the result of another nested query SELECT * FROM purchase WHERE custnum IN ( SELECT custid FROM customer WHERE custname = ‘Weiei Co.’)

Chapter 125 The BETWEEN Operator The BETWEEN operator is used to determine whether a column’s value is between one value and another The use of the BETWEEN operator takes the following form: SELECT column_list FROM table_name WHERE a_column_name BETWEEN value1 AND value2

Chapter 126 Metadata Metadata in a database is data about the database itself, for example, information about the tables, the columns in a table, the column data type, and so on JDBC allows you to access information about the whole database as well as information about a table within a database

Chapter 127 Database Metadata Information about the database Use connection object to get a reference to DatabaseMetaData object, which provides methods to get information about the database DatabaseMetaData dbmd = conn.getMetaData();

Chapter 128 Database Metadata

Chapter 129 Get Information About Table Use ResultSetMetaData object to get table information: ResultSet rst = stm.executeQuery("select * from customer"); ResultSetMetaData rsmd = rst.getMetaData(); ResultSetMetaData object methods: –getColumnCount(), which returns the number of columns in the ResultSet object –getColumnName(int column), which returns the designated column's name, and takes a parameter which is the column number –getColumnDisplaySize(int column), which indicates the designated column's normal maximum width in characters

Chapter 1210 Figure 12-3: Column Data

Chapter 1211 Transactions A transaction is a set of one or more statements that are executed together as a unit, so either all of the statements are executed, or none of the statements are executed Within a transaction, you can actually control when each statement is executed, and when all actions take effect, or even abort the whole transaction (leaving the database unchanged)

Chapter 1212 Auto-Commit Mode Default mode To use transaction control, the auto- commit mode must be set to false: conn.setAutoCommit(false);

Chapter 1213 Committing a Transaction If auto-commit is set to false, all transactions are not complete until the SQL statements are either committed or aborted When a statement is committed, any change made by the SQL statement is reflected in the database; when a statement is aborted, the database remains unchanged To commit a SQL statement, use the following syntax: conn.commit();

Chapter 1214 Abort a Transaction conn.rollBack() Calling this method aborts a transaction and leaves the database unchanged within the current transaction Therefore, you can use the auto-commit mode combined with the commit and rollback methods to control transactions

Chapter 1215 Beans and Databases You can create various beans to facilitate database processing: –A connection bean to connect to a database –A database meta data bean to get database meta information –A table information bean that helps to get table information –A bean that helps to execute SQL statements and displays results