Monday, August 9, 2010

JDBC Database Access with Java













Acknowledgments


Part One
1 Introduction
1.1 Contents of the Book
1.2 What Is JDBC?

1.2.1 What Does JDBC Do?
1.2.2 A Low-level API and a Base for Higher-level APIs
1.2.3 JDBC versus ODBC and other APIs
1.2.4 Two-tier and Three-tier Models
1.2.5 SQL Conformance
1.2.6 JDBC Products
1.2.7 JavaSoft Framework
1.2.8 JDBC Driver Types
1.2.9 Obtaining JDBC Drivers
1.2.10 Other Products

1.3 Java Overview

1.3.1 Java Is Portable
1.3.2 Java Is Object-Oriented
1.3.3 Java Makes It Easy to Write Correct Code
1.3.4 Java Includes a Library of Classes and Interfaces
1.3.5 Java Is Extensible
1.3.6 Java Is Secure
1.3.7 Java Performs Well
1.3.8 Java Scales Well
1.3.9 Java Is Multithreaded

1.4 Relational Database Overview

1.4.1 Integrity Rules
1.4.2 SELECT Statements
1.4.3 WHERE Clauses
1.4.4 Joins
1.4.5 Common SQL Commands
1.4.6 Result Sets and Cursors
1.4.7 Transactions
1.4.8 Stored Procedures
1.4.9 Metadata

2 Basic Tutorial
2.1 Getting Started
2.2 Setting Up a Database
2.3 Establishing a Connection

2.3.1 Loading Drivers
2.3.2 Making the Connection

2.4 Setting Up Tables

2.4.1 Creating a Table
2.4.2 Creating JDBC Statements
2.4.3 Executing Statements
2.4.4 Entering Data into a Table

2.5 Getting Data from a Table
2.6 Retrieving Values from Result Sets

2.6.1 Using the Method next
2.6.2 Using the getXXX Methods
2.6.3 Using the Method getString

2.7 Updating Tables
2.8 Milestone: The Basics of JDBC
2.9 Using Prepared Statements

2.9.1 When to Use a PreparedStatement Object
2.9.2 Creating a PreparedStatement Object
2.9.3 Supplying Values for PreparedStatement Parameters
2.9.4 Using a Loop to Set Values
2.9.5 Return Values for the Method executeUpdate

2.10 Using Joins
2.11 Using Transactions

2.11.1 Disabling Auto-commit Mode
2.11.2 Committing a Transaction
2.11.3 Using Transactions to Preserve Data Integrity
2.11.4 When to Call the Method rollback
2.12 Stored Procedures

2.12.1 SQL Statements for Creating a Stored Procedure

2.12.2 Calling a Stored Procedure from JDBC
2.13 Creating Complete JDBC Applications

2.13.1 Putting Code in a Class Definition
2.13.2 Impoting Classes to Make Them Visible
2.13.3 Using the main Method
2.13.4 Using try and catch Blocks
2.13.5 Retrieving Exceptions
2.13.6 Retrieving Warnings

2.14 Running the Sample Applications
2.15 Sample Code

2.15.1 Sample Code 1 and 2
2.15.2 Sample Code 3 and 4
2.15.3 Sample Code 5
2.15.4 Sample Code 6

2.16 Creating an Applet from an Application

2.16.1 Writing Applet Code
2.16.2 Running an Applet
2.16.3 Sample Code 7 and 8



3 Metadata Tutorial 3.1 Getting Information about a Result Set

3.1.1 Using the Method getColumnCount 3.1.2 Sample Code 9
3.1.3 Using Other ResultSetMetaData Methods
3.1.4 Getting Column Type Information
3.1.5 Sample Code 10 and 11
3.1.6 Sample Code 12
3.1.7 Getting Other Information


3.2 Getting Information about a Database or Database System

3.2.1 Categories of DatabaseMetaData Methods 3.2.2 Methods that Return a String
3.2.3 Methods that Return an int
3.2.4 Methods that Return a boolean
3.2.5 Methods that Return a ResultSet Object
3.2.6 Sample Code 13
3.2.7 Getting Information about DBMS Types
3.2.8 Sample Code 14
3.2.9 Getting Information about Primary and Foreign Keys
3.2.10 Sample Code 15
3.2.11 Sample Code 16


3.3 A Generic Application

3.3.1 Sample Code 17 and 18

Part Two
4 CallableStatement 4.1 CallableStatement Overview

4.1.1 Creating a CallableStatement Object
4.1.2 IN Parameters
4.1.3 OUT Parameters
4.1.4 Numbering of Parameters
4.1.5 INOUT Parameters
4.1.6 Retrieve OUT Parameters after Results
4.1.7 Retrieving NULL Values as OUT Parameters

4.2 CallableStatement Definition
4.3 CallableStatement Methods




5 Connection 5.1 Connection Overview

5.1.1 Opening a Connection
5.1.2 URLs in General Use
5.1.3 JDBC URLs
5.1.4 The odbc Subprotocol
5.1.5 Registering Subprotocols
5.1.6 Sending SQL Statements
5.1.7 Transactions
5.1.8 Transaction Isolation Levels
5.1.9 Using the Method close to Free DBMS Resources

5.2 Connection Interface Definition
5.3 Connection Methods



6 DatabaseMetaData 6.1 DatabaseMetaData Overview

6.1.1 Creating a DatabaseMetaData Object
6.1.2 ResultSet Objects as Return Values
6.1.3 String Patterns as Arguments
6.1.4 Pseudo Columns

6.2 DatabaseMetaData Interface Definition
6.3 DatabaseMetaData Methods
6.4 DatabaseMetaData Fields


7 DataTruncation 7.1 DataTruncation Overview

7.1.1 Data Truncation with No Warning or Exception
7.1.2 Data Truncation on Reads
7.1.3 Data Truncation on Writes
7.1.4 What a DataTruncation Object Contains
7.1.5 Retrieving DataTruncation Information


7.2 DataTruncation Class Definition
7.3 DataTruncation Constructor
7.4 DataTruncation Methods




8 Date 8.1 Date Overview
8.1.1 Creating a Date Object
8.2 Date Class Definition
8.3 Date Constructors
8.4 Date Methods



9 Driver 9.1 Driver Overview

9.1.1 Loading and Registering a Driver
9.1.2 JDBC Implementation Alternatives


9.2 Driver Interface Definition
9.3 Driver Methods




10 DriverManager 10.1 DriverManager Overview

10.1.1 Keeping Track of Available Drivers
10.1.2 Establishing a Connection
10.1.3 DriverManager Methods Are Static


10.2 DriverManager Class Definition
10.3 DriverManager Methods



11 DriverPropertyInfo 11.1 DriverPropertyInfo Overview

11.1.1 Creating a DriverPropertyInfo Object


11.2 DriverPropertyInfo Class Definition
11.3 DriverPropertyInfo Constructor
11.4 DriverPropertyInfo Variables




12 PreparedStatement 12.1 PreparedStatement Overview

12.1.1 Creating PreparedStatement Objects
12.1.2 Passing IN Parameters
12.1.3 Data Type Conformance on IN Parameters
12.1.4 Using setObject
12.1.5 Sending JDBC NULL as an IN parameter
12.1.6 Sending Very Large IN Parameters

12.2 PreparedStatemÄ Interface DefinitioÄÄ
12.3 PÄ Methods



13 ResultSet 13.1 ResultSet Overview

13.1.1 Rows and Cursors
13.1.2 Retrieving Column Values
13.1.3 Datatypes and Conversions
13.1.4 Positioned Updates
13.1.5 Using Streams for Very Large Row Values
13.1.6 NULL Result Values
13.1.7 Optional or Multiple Result Sets
13.1.8 Closing a ResultSet Object


13.2 ResultSet Interface Definition
13.3 ResultSet Methods



14 ResultSetMetaData 14.1 ResultSetMetaData Overview

14.1.1 Creating a ResultSetMetaData Object
14.1.2 Using ResultSetMetaData

14.2 ResultSetMetaData Interface Definition
14.3 ResultSetMetaData Methods
14.4 ResultSetMetaData Fields



15 SQLException 15.1 SQLException Overview

15.1.1 What an SQLException Object Contains
15.1.2 Retrieving SQLException Information
15.1.3 What an SQLException Means


15.2 SQLException Class Definition
15.3 SQLException Constructors
15.4 SQLException Methods



16 SQLWarning 16.1 SQLWarning Overview

16.1.1 What an SQLWarning Object Contains 16.1.2 Retrieving SQLWarning Information

16.2 SQLWarning Class Definition
16.3 SQLWarning Constructors
16.4 SQLWarning Methods


17 Statement 17.1 Statement Overview

17.1.1 Creating Statement Objects
17.1.2 Executing Statements Using Statement Objects
17.1.3 Statement Completion
17.1.4 Closing Statement Objects
17.1.5 SQL Escape Syntax in Statement Objects
17.1.6 Using the Method execute


17.2 Statement Interface Definition
17.3 Statement Methods


18 Time 18.1 Time Overview

18.1.1 Creating a Time Object


18.2 Time Class Definition
18.3 Time Constructors
18.4 Time Methods


19 Timestamp 19.1 Timestamp Overview

19.1.1 Creating a Timestamp Object

19.2 Timestamp Class Definition
19.3 Timestamp Constructors
19.4 Timestamp Methods



20 Types 20.1 Overview of Class Types

20.1.1 Using the Constants in Class Types
20.1.2 Using the Constant OTHER

20.2 Types Class Definition


21 Mapping SQL
and Java Types 21.1 Overview
21.2 Mapping SQL Datatypes into Java
21.3 JDBC Types

21.3.1 CHAR, VARCHAR, LONGVARCHAR
21.3.2 BINARY, VARBINARY, LONGVARBINARY
21.3.3 BIT
21.3.4 TINYINT
21.3.5 SMALLINT
21.3.6 INTEGER
21.3.7 BIGINT
21.3.8 REAL
21.3.9 DOUBLE
21.3.10 FLOAT
21.3.11 DECIMAL and NUMERIC
21.3.12 DATE, TIME, and TIMESTAMP

21.4 Examples of Mapping

21.4.1 Simple SQL Statement
21.4.2 SQL Statement with IN Parameters
21.4.3 SQL Statement with INOUT Parameters


21.5 Dynamic Data Access
21.6 Tables for Type Mapping


21.6.1 JDBC Types Mapped to Java Types
21.6.2 Java Types Mapped to JDBC Types
21.6.3 JDBC Types Mapped to Java Object Types
21.6.4 Java Object Types Mapped to JDBC Types
21.6.5 Conversions by setObject
21.6.6 Types Retrieved by ResultSet.getXXX Methods
21.6.7 Types Mapped to Database-specific SQL Types


Appendix A: For Driver Writers A.1 Requirements for All Drivers

A.1.1 Implement All Methods in the Interfaces
A.1.2 Implement a Special Static Section
A.1.3 Support Extensions to SQL-92 Entry Level
A.1.4 Support Scalar Functions
A.1.5 Provide Locks for Positioned Updates and Deletes
A.1.6 Support Multithreading
A.1.7 Throw Exceptions for Truncated Input Parameters

A.2 Permitted Variants

A.2.1 When Functionality Is Not Supported
A.2.2 Variation in Fundamental Properties
A.2.3 Adding Functionality


A.3 Security Responsibilities of Drivers
A.3.1 Check Shared TCP Connections
A.3.2 Check All Local File Access
A.3.3 Assume the Worst
A.4 SQLExceptions
A.5 Suggested Implementations

A.5.1 Prefetch Rows
A.5.2 Provide "Finalize" Methods for Applets
A.5.3 Avoid Implementation-dependent States


Appendix B: JDBC Design B.1 A Bit of History

B.1.1 How It Started
B.1.2 What Can Be Learned from Our Experience?

B.2 Evolution of JDBC

B.2.1 ResultSet.getXXX Methods
B.2.2 PreparedStatement.setXXX Methods
B.2.3 CallableStatement.registerOutParameter Method
B.2.4 Support for Large OUT Parameters
B.2.5 isNull versus wasNull
B.2.6 Java Type Names or JDBC Type Names
B.2.7 Scrollable Cursors


B.3 Post 1.0 Changes

B.3.1 Numeric to Bignum to BigDecimal
B.3.2 AutoClose Mode Dropped


B.4 The Future of JDBC

Glossary
Quick Reference

Download
Another Database books
Another Java books

No comments:

Post a Comment

Related Posts with Thumbnails

Put Your Ads Here!