You are previewing Expert Oracle JDBC Programming.
O'Reilly logo
Expert Oracle JDBC Programming

Book Description

JDBC is the most commonly used API in Java to access and manipulate data in a database. Oracle is one of the most popular and scalable databases in the world. This book is a must-have for any developer building an application that employs JDBC on Oracle database. Unlike other JDBC books, this book has been written to complement not rehash the contents of Oracle JDBC documentation and the JDBC specification.

The book teaches you not just how to write JDBC code, but how to write effective JDBC code in a step-by-step fashion. This book does not assume any prior knowledge of JDBC, though it does assume basic knowledge of SQL and PL/SQL. It covers JDBC with a focus on writing high-performing, scalable and secure applications for Oracle 10g and 9i.

Table of Contents

  1. Title
  2. Dedication
  3. Contents at a Glance
  4. Contents
  5. About the Author
  6. About the Technical Reviewers
  7. Acknowledgments
  8. Introduction
    1. Who This Book Is For
    2. What This Book Covers
    3. Contacting the Author
  9. About the OakTable Network
    1. The Members
    2. The Politics
    3. The Books
  10. CHAPTER 1: Performance Toolkit
    1. Setting Up the SQL*Plus Environment
    2. Setting Up the SCOTT/TIGER Schema
    3. Setting Up the BENCHMARK/BENCHMARK Schema
    4. Performance Tools
    5. Timing Java Programs
    6. A Utility to Pause in a Java Program
    7. Summary
  11. CHAPTER 2: Oracle Fundamentals
    1. Selected Oracle Concepts
    2. What Makes Oracle Different?
    3. Writing Effective Code
    4. General Guidelines for Writing High-Performance Code
    5. Summary
  12. CHAPTER 3: Introduction to JDBC
    1. What Is JDBC?
    2. JDBC Driver Types
    3. Oracle JDBC Drivers
    4. Choosing the Right Driver
    5. Software Requirements and Setup Instructions
    6. Overview of JDBC API
    7. Connecting to a Database
    8. A Complete JDBC Program
    9. Potential Errors When Executing Your First Program
    10. Exception Handling in JDBC
    11. Introducing JDBCUtil
    12. Summary
  13. CHAPTER 4: Transactions
    1. What Is a Transaction?
    2. Committing a Transaction
    3. Rolling Back a Transaction
    4. Transaction Isolation Levels
    5. Sizing Your Transaction Resources According to Your Business Needs
    6. The Autocommit Feature and Turning It Off
    7. Transaction Savepoints
    8. Summary
  14. CHAPTER 5: Statement and PreparedStatement
    1. Overview of How Oracle Processes SQL Statements (DML)
    2. JDBC API for Statements
    3. The Statement Interface
    4. The PreparedStatement Interface
    5. Update Batching
    6. Summary
  15. CHAPTER 6: CallableStatement
    1. A Brief Introduction to Stored Procedures and PL/SQL
    2. Invoking Stored Procedures from JDBC
    3. CallableStatement Common Errors and Resolutions
    4. Where Should Your SQL Statements Reside, in Java or PL/SQL?
    5. Summary
  16. CHAPTER 7: Result Sets Explored
    1. Handling Null Values
    2. Prefetching
    3. Scrollability, Positioning, and Sensitivity
    4. Updatability
    5. Creating Different Categories of Result Sets
    6. Result Set Limitations and Downgrade Rules
    7. Positioning in a Scrollable Result Set
    8. Updating, Inserting, and Deleting Result Set Rows
    9. Refetching Rows
    10. Database Changes Visible to a Result Set
    11. A Result Set's Ability to Detect Database Changes
    12. Paginating Through a Result Set
    13. Dynamically Building a Query with an Unknown Number of Bind Variables
    14. ResultSetMetaData
    15. DatabaseMetaData
    16. Summary
  17. CHAPTER 8: Oracle Objects: An Objective Analysis
    1. Introducing Oracle Objects and Collections
    2. Using Objects As Programming Constructs
    3. Using Objects to Store Data (Not Recommended)
    4. Using Object Views on Top of Relational Tables
    5. Object Views vs. Nested Tables vs. Relational Tables
    6. Summary
  18. CHAPTER 9: Using Weakly Typed Struct Objects
    1. Weakly Typed Struct Objects
    2. Performing DML Operations Using Struct Objects
    3. Summary
  19. CHAPTER 10: Using Strongly Typed Interfaces with JPublisher
    1. Strongly Typed Interfaces
    2. An Introduction to JPublisher
    3. Using the SQLData Interface
    4. Using the ORAData and ORADataFactory Interfaces
    5. SQLData vs. ORAData and ORADataFactory
    6. A Note on Separating Domain Objects from the Persistence Mechanism
    7. Summary
  20. CHAPTER 11: Using Oracle Collections and References
    1. Weakly Typed Collection Classes
    2. Strongly Typed Collection Classes
    3. Materializing Collections of Built-in Types As Weakly Typed Objects
    4. Materializing Collections of Object Types
    5. ARRAY Class Performance Extensions
    6. References
    7. Summary
  21. CHAPTER 12: Using LOBs and BFILEs
    1. What Are LOBs?
    2. Internal LOBs (CLOBs, NCLOBs, and BLOBs)
    3. External LOBs (BFILEs) in SQL and PL/SQL
    4. Using LOBs in JDBC
    5. Alternatives to BFILEs for File Operations
    6. Summary
  22. CHAPTER 13: Statement Caching
    1. Cursors
    2. Prepare Once, Bind and Execute Many Times
    3. Session Cursor Cache and “Softer” Soft Parses
    4. PL/SQL Cursor Cache
    5. Statement Caching in JDBC
    6. Session Cursor Cache vs. PL/SQL Cursor Cache vs. JDBC Statement Caching
    7. Summary
  23. CHAPTER 14: Connection Pooling and Caching
    1. Connections and Sessions in Oracle
    2. Client/Server Applications and Connections
    3. Web Applications and Connection-Related Challenges
    4. Cost of Opening and Closing a Connection
    5. What Is Connection Pooling?
    6. What Is Connection Caching?
    7. Oracle9i Connection Pooling Framework
    8. Oracle9i Connection Caching
    9. Oracle 10g Implicit Connection Caching
    10. OCI Connection Pooling
    11. Summary
  24. CHAPTER 15: Security-Related Issues
    1. The Principle of Least Privilege and Defense in Depth
    2. Mapping an End User to a Database User
    3. Separating the End User Database Schema, Data Schema, and Data Access Layer Schema
    4. An Example Application
    5. Authenticating an Application End User to the Database
    6. Summary
  25. CHAPTER 16: Locking-Related Issues
    1. Locking in Oracle
    2. Lost Updates
    3. Summary
  26. CHAPTER 17: Selected PL/SQL Techniques
    1. Further Motivation for Using PL/SQL
    2. Common Mistakes When Using PL/SQL
    3. Selected PL/SQL Tips
    4. Summary
  27. Appendix
  28. INDEX