Upload
clara-nicholson
View
220
Download
0
Embed Size (px)
Citation preview
Copyright © 2002 ProsoftTraining. All rights reserved.
Building Database Client Applications Using JDBC 2.0
Copyright © 2002 ProsoftTraining. All rights reserved.
Lesson 1:Introduction
to JDBC
Objectives
• Describe the purpose of JDBC• Discuss the structure of a relational database• Describe the purpose of SQL• Discuss the client-server architecture• Describe the JDBC architecture
JDBC—The Basics
• Sun Java database access API• Microsoft Open Database Connectivity
RelationalDatabases
• Database management systems• Primary keys• Joins
StructuredQuery Language
• DDL• DML• DCL• SQL data types
SystemArchitecture
• Client/server architecture• Three-tier architecture
Summary
Describe the purpose of JDBC Discuss the structure of a relational database Describe the purpose of SQL Discuss the client-server architecture Describe the JDBC architecture
Copyright © 2002 ProsoftTraining. All rights reserved.
Lesson 2:Using JDBC Drivers
Objectives
• Describe the various types of JDBC drivers• Select a JDBC driver• Load a JDBC driver• Establish a connection with a database
JDBCDrivers
• JDBC-ODBC bridge driver• Native-API driver• JDBC-Net driver• Pure Java driver• Loading a driver
Establishinga Connection
• JDBC URLs• The Connection interface
Summary
Describe the various types of JDBC drivers Select a JDBC driver Load a JDBC driver Establish a connection with a database
Copyright © 2002 ProsoftTraining. All rights reserved.
Lesson 3:Executing SQL Statements
Objectives
• Define tables in a database using JDBC• Add new rows to a table using JDBC• Perform queries on a database using JDBC• Extract data from a ResultSet object• Describe the purpose of transactions• Use transactions to maintain data consistency
TheStatement Interface
• Statement interface methods• executeUpdate• executeQuery
TransactionsUsing SQL Statements
• Allow you to group statements so that changes do not take effect until both tables are updated
Summary
Define tables in a database using JDBC Add new rows to a table using JDBC Perform queries on a database using JDBC Extract data from a ResultSet object Describe the purpose of transactions Use transactions to maintain data consistency
Copyright © 2002 ProsoftTraining. All rights reserved.
Lesson 4:Prepared Statements
and Stored Procedures
Objectives
• Describe the purpose of prepared statements• Use prepared statements to increase
efficiency• Describe the purpose of stored procedures• Use stored procedures
PreparedStatements
• PreparedStatement interface• Prepared statement parameters• Executing prepared statements
StoredProcedures
• Precompiled• Stored within the DBMS• Remain permanently within the DBMS
Summary
Describe the purpose of prepared statements Use prepared statements to increase
efficiency Describe the purpose of stored procedures Use stored procedures
Copyright © 2002 ProsoftTraining. All rights reserved.
Lesson 5:Metadata
Objectives
• Describe the purpose of metadata• Extract metadata from a DBMS or database• Extract metadata from a result set
Introductionto Metadata
• Metadata: data about data
DatabaseMetaData
• Determining DBMS product information• Determining supported features• Determining the database schema
ResultSetMetaData
• Extracting metadata from a result set
Summary
Describe the purpose of metadata Extract metadata from a DBMS or database Extract metadata from a result set
Copyright © 2002 ProsoftTraining. All rights reserved.
Lesson 6:SQLExceptions
Objectives
• Describe the purpose of SQLExceptions• Catch SQLExceptions• Determine the cause of a SQLException• Recover efficiently from a SQLException
Introduction to SQLExceptions
• SQLException class helps determine when an error occurs and what type of error has occurred
try and catch Blocks
• catch block accepts an exception and provides some handling for recovering from an exception
• try block may have multiple associated catch blocks
SQLExceptionMethods
• String getMessage( );• String getSQLState( );• int getErrorCode( );• SQLException getNextException( );
Summary
Describe the purpose of SQLExceptions Catch SQLExceptions Determine the cause of a SQLException Recover efficiently from a SQLException
Copyright © 2002 ProsoftTraining. All rights reserved.
Lesson 7:Scrollable and
Updateable Result Sets
Objectives
• Describe the purpose of scrollable result sets• Create and use a scrollable result set• Describe the purpose of updateable result
sets• Create and use an updateable result set
ScrollableResult Sets
• Creating a scrollable result set• Result set type constants• Scrolling through a scrollable result set
UpdateableResult Sets
• Creating an updateable result set• Updating a result set• Inserting a row• Deleting a row
Summary
Describe the purpose of scrollable result sets Create and use a scrollable result set Describe the purpose of updateable result
sets Create and use an updateable result set
Copyright © 2002 ProsoftTraining. All rights reserved.
Lesson 8:Batch Updates
Objectives
• Describe the purpose of batch updates• Perform a batch update• Perform a parameterized batch update• Catch a BatchUpdateException
Introductionto Batch Updates
• Using batch updates– addBatch– executeBatch– clearBatch
ParameterizedBatch Updates
• Combine the benefits of batch updates with those of prepared statements
TheBatchUpdateException Class
• Performing batch updates
Summary
Describe the purpose of batch updates Perform a batch update Perform a parameterized batch update Catch a BatchUpdateException
Building Database Client Applications Using JDBC 2.0
Introduction to JDBC Using JDBC Drivers Executing SQL Statements Prepared Statements and Stored Procedures Metadata
Building Database Client Applications Using JDBC 2.0
SQLExceptions Scrollable and Updateable Result Sets Batch Updates