Acknowledgments | | v | |
Part One | | 3 | (126) |
| | 3 | (30) |
| | 3 | (2) |
| | 5 | (10) |
| | 6 | (1) |
| 1.2.2 A Low-level API and a Base for Higher-level APIs | | | 6 | (1) |
| 1.2.3 JDBC versus ODBC and other APIs | | | 7 | (1) |
| 1.2.4 Two-tier and Three-tier Models | | | 8 | (2) |
| | 10 | (2) |
| | 12 | (1) |
| | 12 | (1) |
| | 12 | (2) |
| 1.2.9 Obtaining JDBC Drivers | | | 14 | (1) |
| | 15 | (1) |
| | 15 | (9) |
| | 15 | (1) |
| 1.3.2 Java Is Object-Oriented | | | 16 | (4) |
| 1.3.3 Java Makes It Easy to Write Correct Code | | | 20 | (1) |
| 1.3.4 Java Includes a Library of Classes and Interfaces | | | 21 | (1) |
| | 22 | (1) |
| | 23 | (1) |
| | 23 | (1) |
| | 24 | (1) |
| 1.3.9 Java Is Multithreaded | | | 24 | (1) |
| 1.4 Relational Database Overview | | | 24 | (9) |
| | 25 | (1) |
| | 26 | (1) |
| | 27 | (1) |
| | 28 | (1) |
| 1.4.5 Common SQL Commands | | | 29 | (1) |
| 1.4.6 Result Sets and Cursors | | | 30 | (1) |
| | 30 | (1) |
| | 31 | (1) |
| | 32 | (1) |
| | 33 | (56) |
| | 33 | (1) |
| 2.2 Setting Up a Database | | | 34 | (1) |
| 2.3 Establishing a Connection | | | 35 | (2) |
| | 35 | (1) |
| 2.3.2 Making the Connection | | | 36 | (1) |
| | 37 | (5) |
| | 37 | (3) |
| 2.4.2 Creating JDBC Statements | | | 40 | (1) |
| 2.4.3 Executing Statements | | | 40 | (1) |
| 2.4.4 Entering Data into a Table | | | 41 | (1) |
| 2.5 Getting Data from a Table | | | 42 | (2) |
| 2.6 Retrieving Values from Result Sets | | | 44 | (3) |
| 2.6.1 Using the Method next | | | 44 | (1) |
| 2.6.2 Using the getXXX Methods | | | 44 | (2) |
| 2.6.3 Using the Method getString | | | 46 | (1) |
| | 47 | (2) |
| 2.8 Milestone: The Basics of JDBC | | | 49 | (1) |
| 2.9 Using Prepared Statements | | | 49 | (4) |
| 2.9.1 When to Use a PreparedStatement Object | | | 49 | (1) |
| 2.9.2 Creating a PreparedStatement Object | | | 50 | (1) |
| 2.9.3 Supplying Values for PreparedStatement Parameters | | | 50 | (2) |
| 2.9.4 Using a Loop to Set Values | | | 52 | (1) |
| 2.9.5 Return Values for the Method executeUpdate | | | 53 | (1) |
| | 53 | (2) |
| | 55 | (4) |
| 2.11.1 Disabling Auto-commit Mode | | | 56 | (1) |
| 2.11.2 Committing a Transaction | | | 56 | (1) |
| 2.11.3 Using Transactions to Preserve Data Integrity | | | 57 | (1) |
| 2.11.4 When to Call the Method rollback | | | 58 | (1) |
| | 59 | (2) |
| 2.12.1 SQL Statements for Creating a Stored Procedure | | | 59 | (1) |
| 2.12.2 Calling a Stored Procedure from JDBC | | | 60 | (1) |
| 2.13 Creating Complete JDBC Applications | | | 61 | (6) |
| 2.13.1 Putting Code in a Class Definition | | | 62 | (1) |
| 2.13.2 Importing Classes to Make Them Visible | | | 62 | (1) |
| 2.13.3 Using the main Method | | | 63 | (1) |
| 2.13.4 Using try and catch Blocks | | | 63 | (1) |
| 2.13.5 Retrieving Exceptions | | | 63 | (2) |
| 2.13.6 Retrieving Warnings | | | 65 | (2) |
| 2.14 Running the Sample Applications | | | 67 | (1) |
| | 68 | (13) |
| 2.15.1 Sample Code 1 and 2 | | | 69 | (4) |
| 2.15.2 Sample Code 3 and 4 | | | 73 | (4) |
| | 77 | (1) |
| | 78 | (3) |
| 2.16 Creating an Applet from an Application | | | 81 | (8) |
| 2.16.1 Writing Applet Code | | | 82 | (2) |
| | 84 | (1) |
| 2.16.3 Sample Code 7 and 8 | | | 85 | (4) |
| | 89 | (40) |
| 3.1 Getting Information about a Result Set | | | 89 | (12) |
| 3.1.1 Using the Method getColumnCount | | | 90 | (1) |
| | 90 | (2) |
| 3.1.3 Using Other ResultSetMetaData Methods | | | 92 | (1) |
| 3.1.4 Getting Column Type Information | | | 93 | (1) |
| 3.1.5 Sample Code 10 and 11 | | | 94 | (3) |
| | 97 | (3) |
| 3.1.7 Getting Other Information | | | 100 | (1) |
| 3.2 Getting Information about a Database or Database System | | | 101 | (15) |
| 3.2.1 Categories of DatabaseMetaData Methods | | | 101 | (1) |
| 3.2.2 Methods that Return a String | | | 101 | (2) |
| 3.2.3 Methods that Return an int | | | 103 | (1) |
| 3.2.4 Methods that Return a boolean | | | 104 | (1) |
| 3.2.5 Methods that Return a ResultSet Object | | | 104 | (1) |
| | 104 | (2) |
| 3.2.7 Getting Information about DBMS Types | | | 106 | (1) |
| | 106 | (4) |
| 3.2.9 Getting Information about Primary and Foreign Keys | | | 110 | (1) |
| | 111 | (3) |
| | 114 | (2) |
| 3.3 A Generic Application | | | 116 | (13) |
| 3.3.1 Sample Code 17 and 18 | | | 117 | (12) |
Part Two | | 129 | (272) |
| | 129 | (14) |
| 4.1 CallableStatement Overview | | | 129 | (5) |
| 4.1.1 Creating a CallableStatement Object | | | 130 | (1) |
| | 130 | (1) |
| | 131 | (1) |
| 4.1.4 Numbering of Parameters | | | 132 | (1) |
| | 132 | (1) |
| 4.1.6 Retrieve OUT Parameters after Results | | | 133 | (1) |
| 4.1.7 Retrieving NULL Values as OUT Parameters | | | 133 | (1) |
| 4.2 CallableStatement Definition | | | 134 | (1) |
| 4.3 CallableStatement Methods | | | 134 | (9) |
| | 143 | (20) |
| | 143 | (7) |
| 5.1.1 Opening a Connection | | | 143 | (1) |
| 5.1.2 URLs in General Use | | | 144 | (1) |
| | 145 | (1) |
| 5.1.4 The odbc Subprotocol | | | 146 | (1) |
| 5.1.5 Registering Subprotocols | | | 147 | (1) |
| 5.1.6 Sending SQL Statements | | | 147 | (1) |
| | 148 | (1) |
| 5.1.8 Transaction Isolation Levels | | | 149 | (1) |
| 5.1.9 Using the Method close to Free DBMS Resources | | | 150 | (1) |
| 5.2 Connection Interface Definition | | | 150 | (1) |
| | 151 | (10) |
| | 161 | (2) |
| | 163 | (84) |
| 6.1 DatabaseMetaData Overview | | | 163 | (3) |
| 6.1.1 Creating a DatabaseMetaData Object | | | 163 | (1) |
| 6.1.2 ResultSet Objects as Return Values | | | 164 | (1) |
| 6.1.3 String Patterns as Arguments | | | 164 | (2) |
| | 166 | (1) |
| 6.2 DatabaseMetaData Interface Definition | | | 166 | (7) |
| 6.3 DatabaseMetaData Methods | | | 173 | (63) |
| 6.4 DatabaseMetaData Fields | | | 236 | (11) |
| | 247 | (6) |
| 7.1 DataTruncation Overview | | | 247 | (2) |
| 7.1.1 Data Truncation with No Warning or Exception | | | 247 | (1) |
| 7.1.2 Data Truncation on Reads | | | 247 | (1) |
| 7.1.3 Data Truncation on Writes | | | 248 | (1) |
| 7.1.4 What a DataTruncation Object Contains | | | 248 | (1) |
| 7.1.5 Retrieving DataTruncation Information | | | 248 | (1) |
| 7.2 DataTruncation Class Definition | | | 249 | (1) |
| 7.3 DataTruncation Constructor | | | 249 | (1) |
| 7.4 DataTruncation Methods | | | 250 | (3) |
| | 253 | (4) |
| | 253 | (1) |
| 8.1.1 Creating a Date Object | | | 253 | (1) |
| 8.2 Date Class Definition | | | 254 | (1) |
| | 254 | (1) |
| | 255 | (2) |
| | 257 | (6) |
| | 257 | (2) |
| 9.1.1 Loading and Registering a Driver | | | 257 | (1) |
| 9.1.2 JDBC Implementation Alternatives | | | 258 | (1) |
| 9.2 Driver Interface Definition | | | 259 | (1) |
| | 259 | (4) |
| | 263 | (10) |
| 10.1 DriverManager Overview | | | 263 | (3) |
| 10.1.1 Keeping Track of Available Drivers | | | 263 | (1) |
| 10.1.2 Establishing a Connection | | | 264 | (1) |
| 10.1.3 DriverManager Methods Are Static | | | 265 | (1) |
| 10.2 DriverManager Class Definition | | | 266 | (1) |
| 10.3 DriverManager Methods | | | 266 | (7) |
| | 273 | (4) |
| 11.1 DriverPropertyInfo Overview | | | 273 | (1) |
| 11.1.1 Creating a DriverPropertyInfo Object | | | 273 | (1) |
| 11.2 DriverPropertyInfo Class Definition | | | 274 | (1) |
| 11.3 DriverPropertyInfo Constructor | | | 274 | (1) |
| 11.4 DriverPropertyInfo Variables | | | 275 | (2) |
| | 277 | (20) |
| 12.1 PreparedStatement Overview | | | 277 | (4) |
| 12.1.1 Creating PreparedStatement Objects | | | 278 | (1) |
| 12.1.2 Passing IN Parameters | | | 278 | (1) |
| 12.1.3 Data Type Conformance on IN Parameters | | | 279 | (1) |
| | 279 | (1) |
| 12.1.5 Sending JDBC NULL as an IN parameter | | | 280 | (1) |
| 12.1.6 Sending Very Large IN Parameters | | | 280 | (1) |
| 12.2 PreparedStatement Interface Definition | | | 281 | (1) |
| 12.3 PreparedStatement Methods | | | 282 | (15) |
| | 297 | (22) |
| | 297 | (6) |
| | 298 | (1) |
| 13.1.2 Retrieving Column Values | | | 298 | (1) |
| 13.1.3 Datatypes and Conversions | | | 299 | (2) |
| 13.1.4 Positioned Updates | | | 301 | (1) |
| 13.1.5 Using Streams for Very Large Row Values | | | 301 | (1) |
| 13.1.6 NULL Result Values | | | 302 | (1) |
| 13.1.7 Optional or Multiple Result Sets | | | 303 | (1) |
| 13.1.8 Closing a ResultSet Object | | | 303 | (1) |
| 13.2 ResultSet Interface Definition | | | 303 | (2) |
| | 305 | (14) |
| | 319 | (12) |
| 14.1 ResultSetMetaData Overview | | | 319 | (2) |
| 14.1.1 Creating a ResultSetMetaData Object | | | 319 | (1) |
| 14.1.2 Using ResultSetMetaData | | | 319 | (2) |
| 14.2 ResultSetMetaData Interface Definition | | | 321 | (1) |
| 14.3 ResultSetMetaData Methods | | | 321 | (8) |
| 14.4 ResultSetMetaData Fields | | | 329 | (2) |
| | 331 | (6) |
| 15.1 SQLException Overview | | | 331 | (2) |
| 15.1.1 What an SQLException Object Contains | | | 331 | (1) |
| 15.1.2 Retrieving SQLException Information | | | 332 | (1) |
| 15.1.3 What an SQLException Means | | | 332 | (1) |
| 15.2 SQLException Class Definition | | | 333 | (1) |
| 15.3 SQLException Constructors | | | 333 | (1) |
| 15.4 SQLException Methods | | | 335 | (2) |
| | 337 | (6) |
| | 337 | (2) |
| 16.1.1 What an SQLWarning Object Contains | | | 337 | (1) |
| 16.1.2 Retrieving SQLWarning Information | | | 338 | (1) |
| 16.2 SQLWarning Class Definition | | | 339 | (1) |
| 16.3 SQLWarning Constructors | | | 339 | (2) |
| | 341 | (2) |
| | 343 | (20) |
| | 343 | (8) |
| 17.1.1 Creating Statement objects | | | 343 | (1) |
| 17.1.2 Executing Statements Using Statement Objects | | | 344 | (1) |
| 17.1.3 Statement Completion | | | 345 | (1) |
| 17.1.4 Closing Statement Objects | | | 345 | (1) |
| 17.1.5 SQL Escape Syntax in Statement Objects | | | 345 | (3) |
| 17.1.6 Using the Method execute | | | 348 | (3) |
| 17.2 Statement Interface Definition | | | 351 | (1) |
| | 352 | (11) |
| | 363 | (4) |
| | 363 | (1) |
| 18.1.1 Creating a Time Object | | | 363 | (1) |
| 18.2 Time Class Definition | | | 364 | (1) |
| | 364 | (1) |
| | 365 | (2) |
| | 367 | (8) |
| | 367 | (1) |
| 19.1.1 Creating a Timestamp Object | | | 367 | (1) |
| 19.2 Timestamp Class Definition | | | 368 | (1) |
| 19.3 Timestamp Constructors | | | 368 | (2) |
| | 370 | (5) |
| | 375 | (4) |
| 20.1 Overview of Class Types | | | 375 | (1) |
| 20.1.1 Using the Constants in Class Types | | | 375 | (1) |
| 20.1.2 Using the Constant OTHER | | | 376 | (1) |
| 20.2 Types Class Definition | | | 376 | (3) |
| 21 Mapping SQL and Java Types | | | 379 | (22) |
| | 379 | (1) |
| 21.2 Mapping SQL Datatypes into Java | | | 379 | (2) |
| | 381 | (7) |
| 21.3.1 CHAR, VARCHAR, LONGVARCHAR | | | 381 | (1) |
| 21.3.2 BINARY, VARBINARY, LONGVARBINARY | | | 382 | (1) |
| | 383 | (1) |
| | 383 | (1) |
| | 384 | (1) |
| | 384 | (1) |
| | 384 | (1) |
| | 384 | (1) |
| | 385 | (1) |
| | 385 | (1) |
| 21.3.11 DECIMAL and NUMERIC | | | 385 | (1) |
| 21.3.12 DATE, TIME, and TIMESTAMP | | | 386 | (2) |
| | 388 | (3) |
| 21.4.1 Simple SQL Statement | | | 388 | (1) |
| 21.4.2 SQL Statement with IN Parameters | | | 388 | (1) |
| 21.4.3 SQL Statement with INOUT Parameters | | | 388 | (3) |
| | 391 | (1) |
| 21.6 Tables for Type Mapping | | | 392 | (9) |
| 21.6.1 JDBC Types Mapped to Java Types | | | 393 | (1) |
| 21.6.2 Java Types Mapped to JDBC Types | | | 394 | (1) |
| 21.6.3 JDBC Types Mapped to Java Object Types | | | 395 | (1) |
| 21.6.4 Java Object Types Mapped to JDBC Types | | | 396 | (1) |
| 21.6.5 Conversions by setObject | | | 397 | (1) |
| 21.6.6 Types Retrieved by ResultSet.getXXX Methods | | | 398 | (1) |
| 21.6.7 Types Mapped to Database-specific SQL Types | | | 399 | (2) |
| Appendix A: For Driver Writers | | | 401 | (14) |
| A.1 Requirements for All Drivers | | | 401 | (8) |
| A.1.1 Implement All Methods in the Interfaces | | | 401 | (1) |
| A.1.2 Implement a Special Static Section | | | 402 | (1) |
| A.1.3 Support Extensions to SQL-92 Entry Level | | | 403 | (1) |
| A.1.4 Support Scalar Functions | | | 404 | (4) |
| A.1.5 Provide Locks for Positioned Updates and Deletes | | | 408 | (1) |
| A.1.6 Support Multithreading | | | 408 | (1) |
| A.1.7 Throw Exceptions for Truncated Input Parameters | | | 409 | (1) |
| | 409 | (1) |
| A.2.1 When Functionality Is Not Supported | | | 410 | (1) |
| A.2.2 Variation in Fundamental Properties | | | 410 | (1) |
| A.2.3 Adding Functionality | | | 410 | (1) |
| A.3 Security Responsibilities of Drivers | | | 410 | (3) |
| A.3.1 Check Shared TCP Connections | | | 411 | (1) |
| A.3.2 Check All Local File Access | | | 412 | (1) |
| | 412 | (1) |
| | 413 | (1) |
| A.5 Suggested Implementations | | | 413 | (2) |
| | 413 | (1) |
| A.5.2 Provide "Finalize" Methods for Applets | | | 413 | (1) |
| A.5.3 Avoid Implementation-dependent States | | | 414 | (1) |
| | 415 | (8) |
| | 415 | (2) |
| | 415 | (1) |
| B.1.2 What Can Be Learned from Our Experience? | | | 416 | (1) |
| | 417 | (3) |
| B.2.1 ResultSet.getXXX Methods | | | 418 | (1) |
| B.2.2 PreparedStatement.setXXX Methods | | | 418 | (1) |
| B.2.3 CallableStatement.registerOutParameter Method | | | 418 | (1) |
| B.2.4 Support for Large OUT Parameters | | | 418 | (1) |
| B.2.5 isNull versus wasNull | | | 419 | (1) |
| B.2.6 Java Type Names or JDBC Type Names | | | 419 | (1) |
| | 420 | (1) |
| | 420 | (1) |
| B.3.1 Numeric to Bignum to BigDecimal | | | 420 | (1) |
| B.3.2 AutoClose Mode Dropped | | | 421 | (1) |
| | 421 | (2) |
Glossary | | 423 | (8) |
Index | | 431 | |