JDBC API Tutorial and Reference, 3/e (Paperback)
暫譯: JDBC API 教程與參考,第3版 (平裝本)

Maydene Fisher, Jon Ellis, Jonathan Bruce

  • 出版商: Addison Wesley
  • 出版日期: 2003-06-21
  • 售價: $2,940
  • 貴賓價: 9.5$2,793
  • 語言: 英文
  • 頁數: 1280
  • 裝訂: Paperback
  • ISBN: 0321173848
  • ISBN-13: 9780321173843
  • 已絕版

買這商品的人也買了...

相關主題

商品描述

This book provides the definitive tutorial and reference to the JDBC™ API, the technology that enables universal data access for the Java™ programming language. This new edition has been updated and expanded to cover the entire JDBC 3.0 API, including the java.sql package and the javax.sql package, the package that facilitates building server-side applications.

Containing in-depth explanations that go beyond the specification, this complete resource pairs a step-by-step tutorial with a comprehensive reference to every class and interface.

For those new to Java technology, the book includes an introduction to the Java programming language and to SQL. It builds on this basic knowledge to walk you through the creation of a JDBC application--from setting up a database and establishing a connection to retrieving values from result sets and using prepared statements. In addition, the authors provide many examples along the way that demonstrate how to execute common tasks. The book then turns to more advanced topics, focusing on features such as scrollable and updatable result sets, batch updates, SQL99 data types, custom mapping, savepoints, statement pooling, automatically generated keys, and more.

In addition to in-depth coverage of the JDBC metadata API, the book gives you the latest information on rowsets, the technology that makes it possible to handle data sets as JavaBeans™ components. As an added bonus, you get a preview of the standard implementations for JdbcRowSet, CachedRowSet, WebRowSet, JoinRowSet, and FilteredRowSet objects.

From Array to XADataSource, an easy-to-use alphabetical reference provides concise but complete information on each class and interface in the JDBC API. Each entry includes an overview with usage examples as well as a comprehensive explanation of the methods and fields.

A chapter on mapping SQL types and types in the Java programming language, an appendix for driver writers, a summary of the new features in the JDBC 2.0 and 3.0 APIs, and a glossary complete this indispensable resource for all database programmers.

The Java™ Series is supported, endorsed, and authored by the creators of the Java technology at Sun Microsystems, Inc. It is the official place to go for complete, expert, and definitive information on Java technology. The books in this Series provide the inside information you need to build effective, robust, and portable applications and applets. The Series is an indispensable resource for anyone targeting the Java™ 2 platform.

Table of Contents

Acknowledgments.

PART ONE.

1. Introduction.

What the JDBC 3.0 API Includes.
Conventions Used in This Book.
Fonts to Indicate Function.
Icons to Indicate New Material.
Special Page Designations in the Index.
SQLException Is Implied in Method Explanations.
Some Method Explanations Are Combined.

Contents of the Book.
Part One.
Part Two.
Suggested Order for Reading Chapters.
Where to Find Information by Topic.
Resources on the Web.

What Is the JDBC API?
What Does the JDBC API Do?
A Base for Other APIs.
The JDBC API versus ODBC.
Two-tier and Three-tier Models.
SQL Conformance.
Products Based on JDBC Technology.
JDBC Product Framework.
JDBC Driver Types.
Obtaining JDBC Drivers.
Java-relational DBMSs.
Other Products.

The JDBC API and the Java Platforms.
The JDBC API and the J2SE Platform.
The JDBC API and the J2EE Platform.
The JDBC API and the J2ME Platform.

Java Overview.
Java Is Portable.
Java Is Object-oriented.
Java Makes It Easy to Write Correct Code.
Java Includes a Library of Classes and Interfaces.
Java Is Extensible.
Java Is Secure.
Java Performs Well.
Java Scales Well.
Java Is Multithreaded.

Relational Database Overview.
Integrity Rules.
SELECT Statements.
WHERE Clauses.
Joins.
Common SQL Commands.
Result Sets and Cursors.
Transactions.
Stored Procedures.
Metadata.


2. Basic Tutorial.

Getting Started.
Setting Up a Database.
Establishing a Connection.
Loading Drivers.
Making the Connection.

Setting Up Tables.
Creating a Table.
Creating JDBC Statements.
Executing Statements.
Entering Data into a Table.

Getting Data from a Table.
Retrieving Values from Result Sets.
Using the Method next.
Retrieving Column Values.
Using the Method getString.

Updating Tables.
Milestone: The Basics of JDBC.
Using Prepared Statements.
When to Use a PreparedStatement Object.
Creating a PreparedStatement Object.
Supplying Values for PreparedStatement Parameters.
Using a Loop to Set Values.
Return Values for the Method executeUpdate.

Using Joins.
Using Transactions.
Disabling Auto-commit Mode.
Committing a Transaction.
Using Transactions to Preserve Data Integrity.
When to Roll Back a Transaction.

Stored Procedures.
SQL Statements for Creating a Stored Procedure.
Calling a Stored Procedure Using the JDBC API.

Creating Complete JDBC Applications.
Putting Code in a Class Definition.
Importing Classes to Make Them Visible.
Using the main Method.
Using try and catch Blocks.
Retrieving Exceptions.
Retrieving Warnings.

Running the Sample Applications.
Sample Code.
Sample Code 1 and 2.
Sample Code 3 and 4.
Sample Code 5.
Sample Code 6.

Creating an Applet from an Application.
Writing Applet Code.
Running an Applet.
Sample Code 7 and 8.

Stored Procedures Using SQLJ and the JDBC API.
Creating a Stored Procedure.
Installing a Stored Procedure.
Declaring a Stored Procedure in SQL.


3. Advanced Tutorial.

Getting Set Up to Use the JDBC 2.0 and 3.0 API.
Setting Up to Run Code.
Using Code Examples.

Moving the Cursor in Scrollable Result Sets.
Creating a Scrollable Result Set.
Moving the Cursor Forward and Backward.
Moving the Cursor to a Designated Row.
Getting the Cursor Position.

Making Updates to Updatable Result Sets.
Creating an Updatable Result Set.
Updating a Result Set Programmatically.
Inserting and Deleting Rows Programmatically.
Sample Code 20.
Deleting a Row Programmatically.
Seeing Changes in Result Sets.
Getting the Most Recent Data.

Making Batch Updates.
Using Statement Objects for Batch Updates.
Batch Update Exceptions.
Sample Code 21.

SQL99 Data Types.
DISTINCT Type.
Using SQL99 Data Types.
Blob, Clob, and Array Objects.
Creating an SQL Structured Type.
Creating a DISTINCT Type.
Sample Code 22.
Using References to Structured Types.
Sample Code 23.
Using SQL99 Types as Column Values.
Sample Code 24.
Inserting SQL99 Types into a Table.
Sample Code 25.

Using Custom Mapping.
Implementing SQLData.
Using a Connection's Type Map.
Using Your Own Type Map.

Using a DataSource Object.
Using a DataSource Object to Get a Connection.
Deploying a Basic DataSource Object.
Deploying Other DataSource Implementations.
Getting and Using a Pooled Connection.
Sample Code 26.
Deployment for Distributed Transactions.
Using Connections for Distributed Transactions.
Sample Code 27.

JDBC 3.0 Functionality.
Using Savepoints.
Sample Code 28.
Using Automatically Generated Keys.
Sample Code 29.


4. MetaData Tutorial.

Using a ResultSetMetaData Object.
Using the Method getColumnCount.
Sample Code 9.
Using Other ResultSetMetaData Methods.
Getting Column Type Information.
Sample Code 10 and 11.
Sample Code 12.
Getting Other Information.
Using ResultSetMetaData Features.
Getting Other Information.

Using a DatabaseMetaData Object.
Categories of DatabaseMetaData Methods.
Methods That Return a String.
Methods That Return an int.
Methods That Return a boolean.
Methods That Return a ResultSet Object.
Sample Code 13.
Getting Information about DBMS Data Types.
Sample Code 14.
Getting Information about Primary and Foreign Keys.
Sample Code 15.
Sample Code 16.

Methods Added in the JDBC 2.0 Core API.
Getting Information about ResultSet Objects.
Getting Other Information.
Methods Added in the JDBC 3.0 API.

Getting Information about ResultSet Objects.
Using a ParameterMetaData Object.
Sample Code.

Generic Applications.
Sample Code 17 and 18.
Sample Code 19.


5. Rowset Tutorial.

Types and Uses of Rowsets.
Using a Rowset.
Creating a Rowset and Setting Properties.
Rowsets and Event Notification.
Obtaining a Scrollable and Updatable Rowset.
Using a Rowset for Scrolling and Updating.
Updating a Rowset.

An EJB Example.
A Distributed Application.
Differences in Rowsets.
EJB and Distributed Transactions.
A Stateless SessionBean Object.
Overview of an EJB Application.
The Remote Interface.
The Home Interface.
The Client Class.
The Enterprise Bean.

PART TWO.



6. Array.

Array Overview.
Creating an Array Object.
Getting Base Type Information.
Materializing Array Data.
Four Versions of the Method getArray.
Four Versions of the Method getResultSet.
Using Array Methods.
Storing Array Objects.

Array Interface Definition.
Array Methods.


7. BatchUpdateException.

BatchUpdateException Overview.
What a BatchUpdateException Object Contains.
Retrieving BatchUpdateException Information.

BatchUpdateException Class Definition.
BatchUpdateException Constructors.
BatchUpdateException Methods.
Inherited Methods.
Methods Defined in BatchUpdateException.


8. Blob.

Blob Overview.
Creating a Blob Object.
Materializing Blob Data.
Storing a Blob Object.
Finding Patterns within a Blob Object.
Methods for Modifying a Blob Object.
Locators and Updates.

Blob Interface Definition.
Blob Methods.


9. CallableStatement.

CallableStatement Overview.
Creating a CallableStatement Object.
Named Parameters.
IN Parameters.
Making Batch Updates.
OUT Parameters.
Numbering of Parameters.
INOUT Parameters.
Retrieving OUT Parameters after Results.
Retrieving NULL Values as OUT Parameters.
Getting Information about Parameters.

CallableStatement Definition.
CallableStatement Methods.
Inherited Methods and Fields.
Methods Defined in CallableStatement.


10. Clob.

Clob Overview.
Creating a Clob Object.
Materializing Clob Data.
Storing a Clob Object.
Updating a Clob Object.
Locators and Updates.

Clob Interface Definition.
Clob Methods.


11. Connection.

Connection Overview.
Opening a Connection.
URLs in General Use.
JDBC URLs.
The odbc Subprotocol.
Registering Subprotocols.
Sending SQL Statements.
Transactions.
Transaction Isolation Levels.
Using Savepoints.
Freeing DBMS Resources.
Using Type Maps.

Connection Interface Definition.
Connection Methods.
Connection Fields.


12. ConnectionEvent.

ConnectionEvent Overview.
ConnectionEvent Interface Definition.
ConnectionEvent Constructors.
ConnectionEvent Methods.
Methods Inherited from javautilEventObject.
Methods Defined in javaxsqlConnectionEvent.


13. ConnectionEventListener.

ConnectionEventListener Overview.
Methods for Event Notification.
Registering a ConnectionEventListener Object.

ConnectionEventListener Interface Definition.
ConnectionEventListener Methods.


14. ConnectionPoolDataSource.

ConnectionPoolDataSource Overview.
Connection and PooledConnection Objects.
Reusing Statements.
Properties for Connection and Statement Pooling.
Closing a Pooled Statement.

ConnectionPoolDataSource Interface Definition.
ConnectionPoolDataSource Methods.


15. DatabaseMetaData.

DatabaseMetaData Overview.
Creating a DatabaseMetaData Object.
ResultSet Objects as Return Values.
String Patterns as Arguments.
Pseudo Columns.
Features Added in the JDBC 2.0 Core API.
Getting Advanced Type Information.
Methods and Fields Added in the JDBC 3.0 API.
Methods Modified in the JDBC 3.0 API.

DatabaseMetaData Interface Definition.
DatabaseMetaData Methods.
DatabaseMetaData Fields.


16. DataSource.

DataSource Overview.
Properties.
Using JNDI.
Creating and Registering a DataSource Object.
Connecting to a Data Source.
DataSource Implementations.
Logging and Tracing.
Advantages of Using JNDI.

DataSource Interface Definition.
DataSource Methods.


17. DataTruncation.

DataTruncation Overview.
Data Truncation with No Warning or Exception.
Data Truncation on Reads.
Data Truncation on Writes.
What a DataTruncation Object Contains.
Retrieving DataTruncation Information.

DataTruncation Class Definition.
DataTruncation Constructor.
DataTruncation Methods.
Inherited Methods.
Methods Defined in DataTruncation.


18. Date.

Date Overview.
Creating a Date Object.
Deprecated Methods.
Retrieving a Date Object.
Advanced Features.

Date Class Definition.
Date Constructors.
Date Methods.


19. Distinct Types.

Distinct Types Overview.
Creating a Distinct Type Object.
Storing Distinct Objects.
Using Distinct Data Types.
Custom Mapping of Distinct Types.


20. Driver.

Driver Overview.
Loading and Registering a Driver.
JDBC Implementation Alternatives.

Driver Interface Definition.
Driver Methods.


21. DriverManager.

DriverManager Overview.
Keeping Track of Available Drivers.
Establishing a Connection.
DriverManager Methods Are Static.

DriverManager Class Definition.
DriverManager Methods.


22. DriverPropertyInfo.

DriverPropertyInfo Overview.
Creating a DriverPropertyInfo Object.
Getting and Setting Fields.

DriverPropertyInfo Class Definition.
DriverPropertyInfo Constructor.
DriverPropertyInfo Fields.


23. ParameterMetaData.

ParameterMetaData Overview.
Creating a ParameterMetaData Object.
Getting Information from a ParameterMetaData Object.
Using Parameter Metadata Wisely.

ParameterMetaData Interface Definition.
ParameterMetaData Methods.
ParameterMetaData Fields.


24. PooledConnection.

PooledConnection Overview.
Application Code for Connection Pooling.
How Connection Pooling Works.
The Life Cycle of a PooledConnection Object.

PooledConnection Interface Definition.
PooledConnection Methods.


25. PreparedStatement.

PreparedStatement Overview.
Creating PreparedStatement Objects.
Passing IN Parameters.
Parameter Metadata.
Data Type Conformance on IN Parameters.
Using setObject.
Sending JDBC NULL as an IN Parameter.
Sending Very Large IN Parameters.
Using PreparedStatement Objects in Batch Updates.
Pooling Prepared Statements.

PreparedStatement Interface Definition.
PreparedStatement Methods.


26. Ref.

Ref Overview.
Creating an SQL Reference.
Creating a Ref Object.
Storing a Ref Object.
Dereferencing a Ref Object.
Sample Code 30.
Modifying a Ref Object.

Ref Interface Definition.
Ref Methods.


27. ResultSet.

ResultSet Overview.
Rows and Columns.
Cursors.
Cursor Movement Examples.
Determining the Number of Rows in a Result Set.
Retrieving Column Values.
Which Method to Use for Retrieving Values.
Using the Method getObject.
Types of Result Sets.
Concurrency Types.
Result Set Holdability.
Providing Performance Hints.
Creating Different Types of Result Sets.
Using a Prepared Statement to Create Result Sets.
Requesting Features That Are Not Supported.
Updating Column Values.
Deleting a Row.
Inserting Rows.
Positioned Updates.
Queries That Produce Updatable Result Sets.
What Is Visible to Transactions.
Visibility of Changes Made by Others.
Visibility of a Result Set's Own Changes.
Detecting Changes.
Refetching a Row.
Using Streams for Very Large Row Values.
NULL Result Values.
Optional or Multiple Result Sets.
Closing a ResultSet Object.
JDBC Compliance.

ResultSet Interface Definition.
ResultSet Methods.
ResultSet Fields.


28. ResultSetMetaData.

ResultSetMetaData Overview.
Creating a ResultSetMetaData Object.
Using ResultSetMetaData.

ResultSetMetaData Interface Definition.
ResultSetMetaData Methods.
ResultSetMetaData Fields.


29. RowSet.

RowSet Overview.
The Event Model for Rowsets.
Properties for a Rowset.
Setting Parameters for the Command String.
Traversing a RowSet Object.
Executing a Command.
Using a RowSet Object's Metadata.

Standard Implementations.
Overview of the JdbcRowSet Implementation.
Overview of the CachedRowSet Implementation.
Uses for a CachedRowSet Object.
Creating a CachedRowSetImpl Object.
Populating a CachedRowSet Object.
Accessing Data.
Modifying Data.
Customizing Readers and Writers.
Other Methods.
WebRowSet Implementation.
FilteredRowSet Implementation.
JoinRowSet Implementation.

RowSet Interface Definition.
RowSet Methods.
RowSet Fields.


30. RowSetEvent.

RowSetEvent Overview.
RowSet Events.
Creating a RowSetEvent Object.

RowSetEvent Interface Definition.
RowSetEvent Constructor.
RowSetEvent Methods.


31. RowSetInternal.

RowSetInternal Overview.
RowSetInternal Interface Definition.
RowSetInternal Methods.


32. RowSetListener.

RowSetListener Overview.
Registering and Deregistering a Listener.
Using RowSetListener Methods.

RowSetListener Interface Definition.
RowSetListener Methods.


33. RowSetMetaData.

RowSetMetaData Overview.
RowSetMetaData Interface Definition.
RowSetMetaData Methods.
RowSetMetaData Fields.


34. RowSetReader.

RowSetReader Overview.
The Reader/Writer Framework.
Reading Data for a Disconnected Rowset.

RowSetReader Interface Definition.
RowSetReader Methods.


35. RowSetWriter.

RowSetWriter Overview.
RowSetWriter Interface Definition.
RowSetWriter Methods.


36. Savepoint.

Savepoint Overview.
Creating a Savepoint Object.
Using a Savepoint Object.
Removing Savepoint Objects.
Retrieving a Savepoint Object Identifier.

Savepoint Interface Definition.
Savepoint Methods.


37. SQLData.

SQLData Overview.
Creating a Custom Mapping.
Retrieving a Custom-mapped Object.
Storing an Object with a Custom Mapping.

SQLData Interface Definition.
SQLData Methods.


38. SQLException.

SQLException Overview.
What an SQLException Object Contains.
Retrieving SQLException Information.
What an SQLException Means.

SQLException Class Definition.
SQLException Constructors.
SQLException Methods.


39. SQLInput.

SQLInput Overview.
Creating an SQLInput Object.
Using reader Methods.

SQLInput Interface Definition.
SQLInput Methods.


40. SQLOutput.

SQLOutput Overview.
SQLOutput Interface Definition.
SQLOutput Methods.


41. SQLPermission.

SQLPermission Overview.
Creating an SQLPermission Object.

SQLPermission Class Definition.
SQLPermission Constructors.


42. SQLWarning.

SQLWarning Overview.
What an SQLWarning Object Contains.
Retrieving SQLWarning Information.

SQLWarning Class Definition.
SQLWarning Constructors.
SQLWarning Methods.


43. Statement.

Statement Overview.
Creating Statement Objects.
Executing Statements Using Statement Objects.
Statement Completion.
Retrieving Automatically Generated Keys.
Closing Statements.
SQL Escape Syntax in Statements.
Sending Batch Updates.
Giving Performance Hints.
Executing Special Kinds of Statements.

Statement Interface Definition.
Statement Methods.
Statement Fields.


44. Struct.

Struct Overview.
Custom Mapping.
Creating an SQL Structured Type.
Storing Instances of a Structured Type.
Creating a Struct Object.
Mapping SQL Inheritance.
Ordering of Attributes.
Storing a Struct Object.

Struct Interface Definition.
Struct Methods.


45. Time.

Time Overview.
Creating a Time Object.
Deprecated Methods.
Retrieving a Time Object.
Advanced Features.

Time Class Definition.
Time Constructors.
Time Methods.


46. Timestamp.

Timestamp Overview.
Creating a Timestamp Object.
Retrieving a Timestamp Object.
Advanced Features.

Timestamp Class Definition.
Timestamp Constructors.
Timestamp Methods.


47. Types.

Overview of Class Types.
Using the Constants in Class Types.
Using the Constant OTHER.
JDBC Types Added in the JDBC 2.0 Core API.
JDBC Data Types Added in the JDBC 3.0 API.

Types Class Definition.


48. XAConnection.

XAConnection Overview.
Application Code in Distributed Transactions.
Distributed Transaction Requirements.
Creating an XAConnection Object.
What an XAResource Object Does.
How the Two-phase Commit Protocol Works.
Using an XAResource Object to Commit.
The XAResource Interface.
Steps in a Distributed Transaction.
Distributed Transactions and EJB.

XAConnection Interface Definition.
XAConnection Methods.


49. XADataSource.

XADataSource Overview.
Obtaining an XADataSource Object.
XADataSource Objects and Resource Managers.

XADataSource Interface Definition.
XADataSource Methods.


50. Mapping SQL and Java Types.

Mapping Overview.
Mapping SQL Types to Java Types.
Basic JDBC Types.
CHAR, VARCHAR, and LONGVARCHAR.
BINARY, VARBINARY, and LONGVARBINARY.
BIT.
TINYINT.
SMALLINT.
INTEGER.
BIGINT.
REAL.
DOUBLE.
FLOAT.
DECIMAL and NUMERIC.
DATE, TIME, and TIMESTAMP.

Advanced JDBC Data Types.
BLOB.
CLOB.
ARRAY.
DISTINCT.
STRUCT.
REF.
JAVA_OBJECT.

JDBC Types Added in the JDBC 3.0 API.
BOOLEAN.
DATALINK.

Examples of Mapping.
Simple SQL Statement.
1079.
SQL Statement with INOUT Parameters.

Custom Mapping.
Dynamic Data Access.
Storing Java Objects in a Database.
Tables for Type Mapping.
JDBC Types Mapped to Java Types.
Java Types Mapped to JDBC Types.
JDBC Types Mapped to Java Object Types.
Java Object Types Mapped to JDBC Type.
Conversions by setObject.
Conversions by ResultSet getter Methods.
JDBC Types Mapped to Database-specific SQL Types.


Appendix A. For Driver Writers.

Requirements for All Drivers.
Guidelines.
Implement Methods in the Interfaces.

Requirements for JDBC 1.0 API Compliance.
Requirements for JDBC 2.0 API Compliance.
Requirements for JDBC 3.0 API Compliance.
API That Is Already Implemented.
Additional Requirements.
Implement a Static Initializer.
Support Extensions to SQL92 Entry Level.
Support Scalar Functions.
Provide Locks for Positioned Updates and Deletes.
Support Multithreading.
Throw Exceptions for Truncated Input Parameters.
Use Default Behaviors for SQL99 Data Types.

Permitted Variants.
When Functionality Is Not Supported.
Variation in Fundamental Properties.
Adding Functionality.

Security Responsibilities of Drivers.
Check Shared TCP Connections.
Check All Local File Access.
Assume the Worst.

Use SQLException for Exceptions.
Implementation Suggestions.
Prefetch Rows.
Provide "Finalize" Methods.
Avoid Implementation-dependent States.

Connection and Statement Pooling Implementations.
JDBC Test Suite.
Connectors.
J2EE Connector Architecture.


Appendix B. Summary of Changes.

Overview of JDBC 3.0 API Changes.
Summary of New Functionality.
Savepoint Support.
Connection Pooling and Reusing Prepared Statements.
Retrieval of Parameter Metadata.
Automatically Generated Keys.
Ability to Have Multiple Open ResultSet Objects.
Holdable Cursor Support.
New Updating Capabilities.
New Data Types.

Complete List of JDBC 3.0 API Changes.
New Interfaces.
New Methods and Fields.

Overview of JDBC 2.0 Core API Changes.
Summary of New Functionality.
Scrollable Result Sets.
Batch Updates.
Programmatic Updates.
Other New Features.
Support for Advanced Data Types.
What Are the SQL99 Data Types?
Summary of Support for the SQL99 Data Types.
Mapping of the New SQL99 Types.
SQL Locators.
Support for Storing Java Objects.

JDBC 2.0 Core API Changes.
What Did Not Change in the JDBC 2.0 API.
Additions to Existing Interfaces and Classes.
Deprecated Methods and Constructors.
New Interfaces, Classes, and Exceptions.

JDBC Optional Package Features.
JNDI.
Connection Pooling.
Support for Distributed Transactions.
Rowsets.

Complete List of Optional Package API.
Post JDBC 1.0 API Changes.
Numeric to Bignum to BigDecimal.
AutoClose Mode Dropped.

Early Design Decisions.
ResultSet getter Methods.
PreparedStatement Methods for Setting Column Values.
CallableStatementregisterOutParameter Method.
Support for Large OUT Parameters.
isNull versus wasNull.
Java Type Names or JDBC Type Names.

Where to Send Suggestions.


Glossary.

商品描述(中文翻譯)

這本書提供了JDBC™ API的權威教程和參考資料,這項技術使Java™程式語言能夠實現通用數據訪問。這一新版已更新並擴展,以涵蓋整個JDBC 3.0 API,包括包和包,後者有助於構建伺服器端應用程序。

本書包含深入的解釋,超越了規範,這個完整的資源將逐步教程與每個類和介面的全面參考相結合。

對於新接觸Java技術的讀者,本書包括Java程式語言和SQL的介紹。它基於這些基本知識,指導您創建一個JDBC應用程序——從設置數據庫和建立連接,到從結果集檢索值和使用預處理語句。此外,作者在過程中提供了許多示例,展示如何執行常見任務。然後,本書轉向更高級的主題,重點介紹可滾動和可更新的結果集、批量更新、SQL99數據類型、自定義映射、保存點、語句池、自動生成的鍵等功能。

除了對JDBC元數據API的深入覆蓋外,本書還提供有關行集的最新信息,這項技術使得可以將數據集作為JavaBeans™組件進行處理。作為額外的獎勵,您將預覽、、、和對象的標準實現。

從到,一個易於使用的字母順序參考提供了有關JDBC API中每個類和介面的簡明但完整的信息。每個條目包括概述和使用示例,以及方法和字段的全面解釋。

本書還包括一章有關SQL類型和Java程式語言類型的映射,為驅動程序編寫者提供的附錄,JDBC 2.0和3.0 API中新功能的摘要,以及一個術語表,這些都使其成為所有數據庫程序員不可或缺的資源。

Java™系列由Sun Microsystems, Inc.的Java技術創建者支持、認可和撰寫。這是獲取有關Java技術的完整、專業和權威信息的官方場所。本系列的書籍提供了構建有效、穩健和可攜帶的應用程序和小應用程序所需的內部信息。該系列是針對Java™ 2平台的任何人的不可或缺的資源。

目錄

致謝。

第一部分。
1. 介紹。
JDBC 3.0 API包含的內容。本書中使用的約定。
指示功能的字體。指示新材料的圖標。索引中的特殊頁面標記。SQLException在方法解釋中隱含。一些方法解釋是合併的。本書內容。
第一部分。第二部分。建議的章節閱讀順序。按主題查找信息的位置。網上的資源。
什麼是JDBC API?
JDBC API的功能。其他API的基礎。JDBC API與ODBC。兩層和三層模型。SQL符合性。基於JDBC技術的產品。JDBC產品框架。JDBC驅動程序類型。獲取JDBC驅動程序。Java關聯DBMS。其他產品。

JDBC API與Java平台。
JDBC API與J2SE平台。JDBC API與J2EE平台。JDBC API與J2ME平台。

Java概述。
Java是可攜帶的。Java是面向對象的。Java使編寫正確代碼變得容易。Java包括類和介面的庫。Java是可擴展的。Java是安全的。Java性能良好。Java擴展性好。Java是多線程的。

關聯數據庫概述。
完整性規則。SELECT語句。WHERE子句。聯接。常見SQL命令。結果集和游標。事務。存儲過程。元數據。

2. 基本教程。
開始使用。設置數據庫。建立連接。
加載驅動程序。建立連接。
設置表格。
創建表格。創建JDBC語句。執行語句。向表格中輸入數據。
從表格中獲取數據。從結果集中檢索值。
使用next方法。檢索列值。使用getString方法。
更新表格。里程碑:JDBC的基礎。使用預處理語句。
何時使用PreparedStatement對象。創建PreparedStatement對象。為PreparedStatement參數提供值。使用循環設置值。executeUpdate方法的返回值。
使用聯接。使用事務。
禁用自動提交模式。提交事務。使用事務來保持數據完整性。何時回滾事務。
存儲過程。
創建存儲過程的SQL語句。使用JDBC API調用存儲過程。
創建完整的JDBC應用程序。
將代碼放入類定義中。導入類以使其可見。使用main方法。使用try和catch塊。檢索異常。檢索警告。
運行示例應用程序。示例代碼。
示例代碼1和2。示例代碼3和4。示例代碼5。示例代碼6。從應用程序創建小應用程序。
編寫小應用程序代碼。運行小應用程序。示例代碼7和8。使用SQLJ和JDBC API的存儲過程。
創建存儲過程。安裝存儲過程。在SQL中聲明存儲過程。

3. 高級教程。
設置以使用JDBC 2.0和3.0 API。
設置以運行代碼。使用代碼示例。
在可滾動結果集中移動游標。
創建可滾動結果集。向前和向後移動游標。將游標移動到指定行。獲取游標位置。
對可更新結果集進行更新。
創建可更新結果集。以編程方式更新結果集。以編程方式插入和刪除行。示例代碼20。以編程方式刪除行。查看結果集中的變更。獲取最新數據。
進行批量更新。
使用語句對象進行批量更新。批量更新異常。示例代碼21。
SQL99數據類型。
DISTINCT類型。使用SQL99數據類型。Blob、Clob和Array對象。創建SQL結構類型。創建DISTINCT類型。示例代碼22。使用對結構類型的引用。示例代碼23。將SQL99類型用作列值。示例代碼24。將SQL99類型插入表格。示例代碼25。
使用自定義映射。
實現SQLData。使用連接的類型映射。使用自己的類型映射。
使用DataSource對象。
使用DataSource對象獲取連接。部署基本DataSource對象。部署其他DataSource實現。獲取和使用池化連接。示例代碼26。分佈式事務的部署。使用連接進行分佈式事務。示例代碼27。
JDBC 3.0功能。
使用保存點。示例代碼28。使用自動生成的鍵。示例代碼29。

4. 元數據教程。
使用ResultSetMetaData對象。
使用getColumnCount方法。示例代碼9。使用其他ResultSetMetaData方法。獲取列類型信息。示例代碼10和11。示例代碼12。獲取其他信息。使用ResultSetMetaData功能。獲取其他信息。
使用DatabaseMetaData對象。
DatabaseMetaData方法的類別。返回字符串的方法。返回int的方法。返回boolean的方法。返回ResultSet對象的方法。示例代碼13。獲取有關DBMS數據類型的信息。示例代碼14。獲取有關主鍵和外鍵的信息。示例代碼15。示例代碼16。
在JDBC 2.0核心API中添加的方法。
獲取有關ResultSet對象的信息。獲取其他信息。在JDBC 3.0 API中添加的方法。
獲取有關ResultSet對象的信息。使用ParameterMetaData對象。
示例代碼。通用應用程序。
示例代碼17和18。示例代碼19。

5. 行集教程。
行集的類型和用途。使用行集。
創建行集並設置屬性。行集和事件通知。獲取可滾動和可更新的行集。使用行集進行滾動和更新。更新行集。
EJB示例。
分佈式應用程序。行集的差異。EJB和分佈式事務。無狀態SessionBean對象。EJB應用程序概述。遠程介面。主介面。客戶端類。企業Bean。