Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

JDBC API Tutorial And Reference
Nội dung xem thử
Mô tả chi tiết
• Table of Contents
• Index
JDBC™ API Tutorial and Reference, Third Edition
By Maydene Fisher, Jon Ellis, Jonathan Bruce
Publisher: Addison Wesley
Pub Date: June 13, 2003
ISBN: 0-321-17384-8
Pages: 1280
Slots: 2
This book provides the definitive tutorial and reference to the JDBC(TM) API, the technology that
enables universal data access for the Java(TM) 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(TM) 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(TM) 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(TM) 2 platform.
• Table of Contents
• Index
JDBC™ API Tutorial and Reference, Third Edition
By Maydene Fisher, Jon Ellis, Jonathan Bruce
Publisher: Addison Wesley
Pub Date: June 13, 2003
ISBN: 0-321-17384-8
Pages: 1280
Slots: 2
Copyright
The Java™ Series
The Jini™ Technology Series
The Java™ Series, Enterprise Edition
Acknowledgments
Part One
Chapter 1. Introduction
Section 1.1. What the JDBC 3.0 API Includes
Section 1.2. Conventions Used in This Book
Section 1.3. Contents of the Book
Section 1.4. What Is the JDBC API?
Section 1.5. The JDBC API and the Java Platforms
Section 1.6. Java Overview
Section 1.7. Relational Database Overview
Chapter 2. Basic Tutorial
Section 2.1. Getting Started
Section 2.2. Setting Up a Database
Section 2.3. Establishing a Connection
Section 2.4. Setting Up Tables
Section 2.5. Getting Data from a Table
Section 2.6. Retrieving Values from Result Sets
Section 2.7. Updating Tables
Section 2.8. Milestone: The Basics of JDBC
Section 2.9. Using Prepared Statements
Section 2.10. Using Joins
Section 2.11. Using Transactions
Section 2.12. Stored Procedures
Section 2.13. Creating Complete JDBC Applications
Section 2.14. Running the Sample Applications
Section 2.15. Sample Code
Section 2.16. Creating an Applet from an Application
Section 2.17. Stored Procedures Using SQLJ and the JDBC API
Chapter 3. Advanced Tutorial
Section 3.1. Getting Set Up to Use the JDBC 2.0 and 3.0 API
Section 3.2. Moving the Cursor in Scrollable Result Sets
Section 3.3. Making Updates to Updatable Result Sets
Section 3.4. Making Batch Updates
Section 3.5. SQL99 Data Types
Section 3.6. Using Custom Mapping
Section 3.7. Using a DataSource Object
Section 3.8. JDBC 3.0 Functionality
Chapter 4. MetaData Tutorial
Section 4.1. Using a ResultSetMetaData Object
Section 4.2. Using a DatabaseMetaData Object
Section 4.3. Methods Added in the JDBC 2.0 Core API
Section 4.4. Methods Added in the JDBC 3.0 API
Section 4.5. Using a ParameterMetaData Object
Section 4.6. Generic Applications
Chapter 5. Rowset Tutorial
Section 5.1. Types and Uses of Rowsets
Section 5.2. Using a Rowset
Section 5.3. An EJB Example
Part Two
Chapter 6. Array
Section 6.1. Array Overview
Section 6.2. Array Interface Definition
Section 6.3. Array Methods
Chapter 7. BatchUpdateException
Section 7.1. BatchUpdateException Overview
Section 7.2. BatchUpdateException Class Definition
Section 7.3. BatchUpdateException Constructors
Section 7.4. BatchUpdateException Methods
Chapter 8. Blob
Section 8.1. Blob Overview
Section 8.2. Blob Interface Definition
Section 8.3. Blob Methods
Chapter 9. CallableStatement
Section 9.1. CallableStatement Overview
Section 9.2. CallableStatement Definition
Section 9.3. CallableStatement Methods
Chapter 10. Clob
Section 10.1. Clob Overview
Section 10.2. Clob Interface Definition
Section 10.3. Clob Methods
Chapter 11. Connection
Section 11.1. Connection Overview
Section 11.2. Connection Interface Definition
Section 11.3. Connection Methods
Section 11.4. Connection Fields
Chapter 12. ConnectionEvent
Section 12.1. ConnectionEvent Overview
Section 12.2. ConnectionEvent Interface Definition
Section 12.3. ConnectionEvent Constructors
Section 12.4. ConnectionEvent Methods
Chapter 13. ConnectionEventListener
Section 13.1. ConnectionEventListener Overview
Section 13.2. ConnectionEventListener Interface Definition
Section 13.3. ConnectionEventListener Methods
Chapter 14. ConnectionPoolDataSource
Section 14.1. ConnectionPoolDataSource Overview
Section 14.2. ConnectionPoolDataSource Interface Definition
Section 14.3. ConnectionPoolDataSource Methods
Chapter 15. DatabaseMetaData
Section 15.1. DatabaseMetaData Overview
Section 15.2. DatabaseMetaData Interface Definition
Section 15.3. DatabaseMetaData Methods
Section 15.4. DatabaseMetaData Fields
Chapter 16. DataSource
Section 16.1. DataSource Overview
Section 16.2. DataSource Interface Definition
Section 16.3. DataSource Methods
Chapter 17. DataTruncation
Section 17.1. DataTruncation Overview
Section 17.2. DataTruncation Class Definition
Section 17.3. DataTruncation Constructor
Section 17.4. DataTruncation Methods
Chapter 18. Date
Section 18.1. Date Overview
Section 18.2. Date Class Definition
Section 18.3. Date Constructors
Section 18.4. Date Methods
Chapter 19. Distinct Types
Section 19.1. Distinct Types Overview
Chapter 20. Driver
Section 20.1. Driver Overview
Section 20.2. Driver Interface Definition
Section 20.3. Driver Methods
Chapter 21. DriverManager
Section 21.1. DriverManager Overview
Section 21.2. DriverManager Class Definition
Section 21.3. DriverManager Methods
Chapter 22. DriverPropertyInfo
Section 22.1. DriverPropertyInfo Overview
Section 22.2. DriverPropertyInfo Class Definition
Section 22.3. DriverPropertyInfo Constructor
Section 22.4. DriverPropertyInfo Fields
Chapter 23. ParameterMetaData
Section 23.1. ParameterMetaData Overview
Section 23.2. ParameterMetaData Interface Definition
Section 23.3. ParameterMetaData Methods
Section 23.4. ParameterMetaData Fields
Chapter 24. PooledConnection
Section 24.1. PooledConnection Overview
Section 24.2. PooledConnection Interface Definition
Section 24.3. PooledConnection Methods
Chapter 25. PreparedStatement
Section 25.1. PreparedStatement Overview
Section 25.2. PreparedStatement Interface Definition
Section 25.3. PreparedStatement Methods
Chapter 26. Ref
Section 26.1. Ref Overview
Section 26.2. Ref Interface Definition
Section 26.3. Ref Methods
Chapter 27. ResultSet
Section 27.1. ResultSet Overview
Section 27.2. ResultSet Interface Definition
Section 27.3. ResultSet Methods
Section 27.4. ResultSet Fields
Chapter 28. ResultSetMetaData
Section 28.1. ResultSetMetaData Overview
Section 28.2. ResultSetMetaData Interface Definition
Section 28.3. ResultSetMetaData Methods
Section 28.4. ResultSetMetaData Fields
Chapter 29. RowSet
Section 29.1. RowSet Overview
Section 29.2. Standard Implementations
Section 29.3. RowSet Interface Definition
Section 29.4. RowSet Methods
Section 29.5. RowSet Fields
Chapter 30. RowSetEvent
Section 30.1. RowSetEvent Overview
Section 30.2. RowSetEvent Interface Definition
Section 30.3. RowSetEvent Constructor
Section 30.4. RowSetEvent Methods
Chapter 31. RowSetInternal
Section 31.1. RowSetInternal Overview
Section 31.2. RowSetInternal Interface Definition
Section 31.3. RowSetInternal Methods
Chapter 32. RowSetListener
Section 32.1. RowSetListener Overview
Section 32.2. RowSetListener Interface Definition
Section 32.3. RowSetListener Methods
Chapter 33. RowSetMetaData
Section 33.1. RowSetMetaData Overview
Section 33.2. RowSetMetaData Interface Definition
Section 33.3. RowSetMetaData Methods
Section 33.4. RowSetMetaData Fields
Chapter 34. RowSetReader
Section 34.1. RowSetReader Overview
Section 34.2. RowSetReader Interface Definition
Section 34.3. RowSetReader Methods
Chapter 35. RowSetWriter
Section 35.1. RowSetWriter Overview
Section 35.2. RowSetWriter Interface Definition
Section 35.3. RowSetWriter Methods
Chapter 36. Savepoint
Section 36.1. Savepoint Overview
Section 36.2. Savepoint Interface Definition
Section 36.3. Savepoint Methods
Chapter 37. SQLData
Section 37.1. SQLData Overview
Section 37.2. SQLData Interface Definition
Section 37.3. SQLData Methods
Chapter 38. SQLException
Section 38.1. SQLException Overview
Section 38.2. SQLException Class Definition
Section 38.3. SQLException Constructors
Section 38.4. SQLException Methods
Chapter 39. SQLInput
Section 39.1. SQLInput Overview
Section 39.2. SQLInput Interface Definition
Section 39.3. SQLInput Methods
Chapter 40. SQLOutput
Section 40.1. SQLOutput Overview
Section 40.2. SQLOutput Interface Definition
Section 40.3. SQLOutput Methods
Chapter 41. SQLPermission
Section 41.1. SQLPermission Overview
Section 41.2. SQLPermission Class Definition
Section 41.3. SQLPermission Constructors
Chapter 42. SQLWarning
Section 42.1. SQLWarning Overview
Section 42.2. SQLWarning Class Definition
Section 42.3. SQLWarning Constructors
Section 42.4. SQLWarning Methods
Chapter 43. Statement
Section 43.1. Statement Overview
Section 43.2. Statement Interface Definition
Section 43.3. Statement Methods
Section 43.4. Statement Fields
Chapter 44. Struct
Section 44.1. >Struct Overview
Section 44.2. Struct Interface Definition
Section 44.3. Struct Methods
Chapter 45. Time
Section 45.1. Time Overview
Section 45.2. Time Class Definition
Section 45.3. Time Constructors
Section 45.4. Time Methods
Chapter 46. Timestamp
Section 46.1. Timestamp Overview
Section 46.2. Timestamp Class Definition
Section 46.3. Timestamp Constructors
Section 46.4. Timestamp Methods
Chapter 47. Types
Section 47.1. Overview of Class Types
Section 47.2. Types Class Definition
Chapter 48. XAConnection
Section 48.1. XAConnection Overview
Section 48.2. XAConnection Interface Definition
Section 48.3. XAConnection Methods
Chapter 49. XADataSource
Section 49.1. XADataSource Overview
Section 49.2. XADataSource Interface Definition
Section 49.3. XADataSource Methods
Chapter 50. Mapping SQL and Java Types
Section 50.1. Mapping Overview
Section 50.2. Mapping SQL Types to Java Types
Section 50.3. Basic JDBC Types
Section 50.4. Advanced JDBC Data Types
Section 50.5. JDBC Types Added in the JDBC 3.0 API
Section 50.6. Examples of Mapping
Section 50.7. Custom Mapping
Section 50.8. Dynamic Data Access
Section 50.9. Storing Java Objects in a Database
Section 50.10. Tables for Type Mapping
Appendix A. For Driver Writers
Section A.1. Requirements for All Drivers
Section A.2. Requirements for JDBC 1.0 API Compliance
Section A.3. Requirements for JDBC 2.0 API Compliance
Section A.4. Requirements for JDBC 3.0 API Compliance
Section A.5. API That Is Already Implemented
Section A.6. Additional Requirements
Section A.7. Permitted Variants
Section A.8. Security Responsibilities of Drivers
Section A.9. Use SQLException for Exceptions
Section A.10. Implementation Suggestions
Section A.11. Connection and Statement Pooling Implementations
Section A.12. JDBC Test Suite
Section A.13. Connectors
Appendix B. Summary of Changes
Section B.1. Overview of JDBC 3.0 API Changes
Section B.2. Summary of New Functionality
Section B.3. Complete List of JDBC 3.0 API Changes
Section B.4. Overview of JDBC 2.0 Core API Changes
Section B.5. Summary of New Functionality
Section B.6. JDBC 2.0 Core API Changes
Section B.7. JDBC Optional Package Features
Section B.8. Complete List of Optional Package API
Section B.9. Post JDBC 1.0 API Changes
Section B.10. Early Design Decisions
Section B.11. Where to Send Suggestions
Glossary
JDBC Quick Reference
Index
Copyright
Copyright © 2003 Sun Microsystems, Inc.
4150 Network Circle, Santa Clara, California 95054, U.S.A.
All rights reserved.
Sun, Sun Microsystems, the Sun logo, Java, Java 2 Platform, Enterprise Edition, Java 2 Platform,
Standard Edition, J2EE, J2SE, JDBC, Enterprise JavaBeans, EJB, Java Naming and Directory Interface,
Java Data Objects, JavaBeans, SunONE, the Duke logo and the Java Coffee Cup logo are trademarks
or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.UNIX is a
registered trademark in the U.S. and other countries, exclusively licensed through X/Open Company,
Ltd. X/Open is a registered trademark of X/Open Company, Ltd.
THIS PUBLICATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR
IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
THIS PUBLICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS.
CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION HEREIN; THESE CHANGES WILL BE
INCORPORATED IN NEW EDITIONS OF THE PUBLICATION. SUN MICROSYSTEMS, INC. MAY MAKE
IMPROVEMENTS AND/OR CHANGES IN THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN
THIS PUBLICATION AT ANY TIME.
Library of Congress Cataloging-in-Publication Data
Fisher, Maydene.
JDBC API tutorial and reference / Maydene Fisher, Jon Ellis, Jonathan Bruce. —3rd ed.
p. cm.
ISBN 0-321-17384-8 (alk. paper)
1. Internet programming. 2. Database management. 3. Java (Computer program language) I. Ellis,
Jonathan. II. Bruce, Jonathan. III. Title.
QA76.625.F57 2003
005.75'6—dc21
2003050236
The publisher offers discounts on this book when ordered in quantity for bulk purchases and special
sales. For more information, please contact U.S. Corporate and Government Sales, (800) 382-3419,
corpsales@pearsontechgroup.com.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or
transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording, or
otherwise, without the prior consent of the publisher. Printed in the United States of America.
Published simultaneously in Canada.
For information on obtaining permission for use of material from this work, please submit a written
request to:
Pearson Education, Inc., Rights and Contracts Department,
75 Arlington Street, Suite 300, Boston, MA 02116
Fax: (617) 848-7047
Text printed on recycled paper
1 2 3 4 5 6 7 8 9 10—CRS—0706050403
First printing, June 2003
The Java™ Series
Lisa Friendly, Series Editor
Tim Lindholm, Technical Editor
Ken Arnold, Technical Editor of The JiniTM Technology Series
Jim Inscore, Technical Editor of The JavaTM Series, Enterprise Edition http://www.javaseries.com
Eric Armstrong, Stephanie Bodoff, Debbie Carson, Maydene Fisher, Dale Green, Kim Haase
The Java™ Web Services Tutorial
Ken Arnold, James Gosling, David Holmes
The Java™ Programming Language, Third Edition
Cindy Bloch, Annette Wagner
MIDP 2.0 Style Guide
Joshua Bloch
Effective Java™ Programming Language Guide
Mary Campione, Kathy Walrath, Alison Huml
The Java™ Tutorial, Third Edition: A Short Course on the Basics
Mary Campione, Kathy Walrath, Alison Huml,Tutorial Team
The Java™ Tutorial Continued: The Rest of the JDK™
Patrick Chan
The Java™ Developers Almanac 1.4, Volume 1
Patrick Chan
The Java™ Developers Almanac 1.4, Volume 2
Patrick Chan, Rosanna Lee
The Java™ Class Libraries, Second Edition, Volume 2: java.applet, java.awt, java.beans
Patrick Chan, Rosanna Lee, Doug Kramer
The Java™ Class Libraries, Second Edition, Volume 1: java.io, java.lang, java.math, java.net,
java.text, java.util
Patrick Chan, Rosanna Lee, Doug Kramer
The Java Class Libraries, Second Edition, Volume 1: Supplement for the Java™ 2 Platform, Standard
Edition, v1.2
Kirk Chen, Li Gong
Programming Open Service Gateways with Java™ Embedded Server
Zhiqun Chen
Java Card™ Technology for Smart Cards: Architecture and Programmer's Guide
Maydene Fisher, Jon Ellis, Jonathan Bruce
JDBC™ API Tutorial and Reference, Third Edition
Li Gong, Gary Ellison, Mary Dageforde
Inside Java™ 2 Platform Security, Second Edition: Architecture, API Design, and Implementation
James Gosling, Bill Joy, Guy Steele, Gilad Bracha
The Java™ Language Specification, Second Edition
Doug Lea
Concurrent Programming in Java™, Second Edition: Design Principles and Patterns
Rosanna Lee, Scott Seligman
JNDI API Tutorial and Reference: Building Directory-Enabled Java™ Applications
Sheng Liang
The Java™ Native Interface: Programmer's Guide and Specification
Tim Lindholm, Frank Yellin
The Java™ Virtual Machine Specification, Second Edition
Roger Riggs, Antero Taivalsaari, Jim Van Peursem, Jyri Huopaniemi, Mark Patel, Aleksi Uotila
Programming Wireless Devices with the Java™ 2 Platform, Micro Edition, Second Edition
Henry Sowizral, Kevin Rushforth, Michael Deering
The Java 3D™ API Specification, Second Edition
Sun Microsystems, Inc.
Java™ Look and Feel Design Guidelines: Advanced Topics
Kathy Walrath, Mary Campione
The JFC Swing Tutorial: A Guide to Constructing GUIs
Seth White, Maydene Fisher, Rick Cattell, Graham Hamilton, Mark Hapner
JDBC™ API Tutorial and Reference, Second Edition: Universal Data Access for the Java™ 2 Platform
Steve Wilson, Jeff Kesselman
Java™ Platform Performance: Strategies and Tactics
The Jini™ Technology Series
Eric Freeman, Susanne Hupfer, Ken Arnold
JavaSpaces™ Principles, Patterns, and Practice