JDBC Recipes 原版pdf by Parsian

所需积分/C币:12 2018-04-28 13:20:50 5.47MB PDF

This chapter defines some key terms for the remaining chapters. JDBC is a platform-independent interface between relational databases and Java. In today’s Java world, JDBC is a standard application programming interface (API) for accessing enterprise data in relational databases (such as Oracle, MyS
5203ch00_FM. gxd 8/12/05 12: 17 PM Page ii JDBC Recipes: A Problem-Solution Approach Copyright@ 2005 by Mahmoud Parsian All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher ISBN:1-59059-520-3 Printed and bound in the united states of america 987654321 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark Lead editor: Steve angli Development Editor: Jim Sumser Technical reviewer: Sumit pal Editorial Board: Steve Anglin, Dan Appleman, Ewan Buckingham, Gary Cornell, Tony Davis, Jason Gilmore, Jonathan Hassell, Chris Mills, Dominic Shakeshaft, Jim Sumser Associate Publisher Grace Wong Project Manager: Beckie Stones Copy Edit Manager: Nicole LeClerc Copy Editor: Kim Wimpsett Assistant Production Director: Kari Brooks-Copony Production Editor: Katie Stence Compositor and Artist: Kinetic Publishing Services, LLC Proofreaders: Liz Welch and Lori Bring Indexer: Tim Tate Interior Designer: Van Winkle Design group Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, InC, 233 Spring Street, 6th Floor, NewyOrk,Ny10013.Phone1-800-springer,fax201-348-4505,e-mailorders-ny@springer-sbm.com,or visithttp://www.springeronline.com For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley Ca94710.Phone510-549-5930,fax510-549-5939,e-mailinfo@apress.comorvisithttp://www.apress.com The information in this book is distributed on an"as is"basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work Thesourcecodeforthisbookisavailabletoreadersathttp://www.apress.comintheSourceCodesection 5203ch00_FM. gxd 8/12/05 12: 17 PM Page v Contents at a glance Introduction XXV CHAPTER 1 Introducing JDBC CHAPTER 2 Exploring JDBC,s Novel Features 45 CHAPTER 3 Making Database Connections CHAPTER 4 Making Database Connections Using DataSource ....153 CHAPTER 5 Exploring the ResultSet Interface .169 CHAPTER 6 Working with Scrollable and Updatable ResultSet Objects 209 CHAPTER 7 Reading and Writing blobs CHAPTER 8 Reading and Writing CLOBs 257 CHAPTER 9 Working with Date, Time, and Timestamp in JDBC 307 CHAPTER 10 Handling Exceptions in JDBC ..341 CHAPTER 11 Exploring the Statement CHAPTER 12 Working with the PreparedStatement .431 CHAPTER 13 Passing Input Parameters to PreparedStatement CHAPTER 14 Exploring JDBC Utilities .569 INDEX 615 5203ch00_FM. gxd 8/12/05 12: 17 PM Page vi 5203ch00_FM. gxd 8/12/05 12: 17 PM Page vi Contents Introduction.,,,,,,,,,,,,,,,,,,,, XXV CHAPTER 1 Introducing JDBC 1-1. What Is jdbc? 1-2. What Is JDBC's High-Level Architecture? 1-3. What Is jdBC's detailed Architecture? 1-4. What ls a relational database? 1-5. What Is odbc? 1-6. What Is a JDBC-ODBC Bridge? 1-7 What Is sql? 3366835 1-8. What Is JDBC Programming? 1-9. What Is the JDBC APl(in a Nutshell)? 1-10. What are the core jdbc classes/Interfaces? 1-11. What is a jdbc driver? 6679 1-12. How do You load a jdbc driver? 1-13. How Do You test a jdbc driver Installation? 1-14. Where Can You obtain a jdbc Driver for your database System? 34 1-15. What is a JDBC Driver Type? 1-16. What Types of JDBC Drivers Exist? 35 1-17 What are the selection criteria for jdbc drivers? 1-18. What Is the URL Syntax for Connecting to a Database 38 1-19. What Is the Mapping between Java to JDBC SQL Types? .39 1-20. How Do You Handle JDBC Errors/Exceptions? CHAPTER 2 Exploring JDBC's Novel Features 45 2-1. What is database metadata? 2-2. What is a transaction? 2-3. How Do You turn on autocommit Mode? 48 2-4. How Do You turn off autocommit mode? .48 2-5. How do you roll back a transaction? 48 5203ch00_FM. gxd 8/12/05 12: 17 PM Page viii viIi CONTENTS 2-6. How Do you start and end a transaction in jDBC?,.....48 2-7. What is Connection Pool Management? 49 2-8. How Do You Improve the performance of jdbc applications? ..... 51 2-9. What are oracle s jDbc Drivers? 2-10. How Do You connect with oracle' s jdBc Thin Driver? ..64 2-11. How do You connect with oracle's jdbc ocl Driver? 2-12. How Do You connect with oracle s KPRb Driver? 2-13. What Are MySQL's JDBC Drivers? 2-14. How do You register the mysQL Driver with the Driver Manager? 2-15. How Do You get a mySQL Connection from the Driver Manager? 555669 2-16. What are the Key jdbc concepts for an oracle database 2-17. What Are the Key jDBC Concepts for a mySQL Database? ..72 2-18. How Do You set your environment for jdbC? ....73 2-19. What are some jdbc resources? 74 2-20. How Do You Debug problems related to the JDBC API? 75 2-21. Does MySQL Support Transactions 2-22. Does Oracle Support transaction 77 2-23. What do the different versions of jdbc offer? 2-24. What Is the core functionality of a JDBC DI 79 2-25. Where Can You Find Information and Pointers for Writing a jdbc Driver? 82 2-26. What Is the JDbC Driver Certification Program? 82 2-27. What is a two-tier model for jdbc? 83 2-28. What is a three-Tier model for jdbc? CHAPTER 3 Making Database Connections 3-1. What Is a connection Object? 3-2. What Is the Relationship of Connection to other Objects? 3-3. What are the Connection Creation Options? 88g 3-4. What is the Function of the driverManager class? 3-5. How Do You Create Connection(s) Using the Driver Manager Class 3-6. How Do you get a list of loaded drivers? 3-7. How Do you connect to an oracle database? 97 3-8. How Do You connect to a MySQL Database? 100 3-9. How Do You get a List of All Available Parameters for Creating a jdBC Connection? 3-10. How Do You Create Connection(s) Using the Driver Interface?.... 106 3-11. What is Basic connection Management? 3-12. How Do You Determine If a Database Supports transactions?....113 5203ch00_FM. gxd 8/12/05 12: 17 PM Page ix CONTENTS 3-13. How Do You limit the number of rows returned from a SQL Query?.… 3-14. How Do You get the driver of a connection? ...117 3-15. How do You commit and roll back Updates to a database? 3-16. How Do You Determine If a SQL Warning occurs? ...119 3-17. What Are the MySQL Connection Properties 121 3-18. What Are the Oracle Connection Properties? .123 3-19. Can a JDBC Application Connect to More Than One Database? 124 3-20. How Do You test to see if your connection is alive?.,.,,., 125 3-21. How Do You Keep the Connection Alive in a Production Environment? 130 3-22. How Do you disconnect from a database? .131 3-23. What are the rules for connections autocommit?.,, 132 3-24. How Do You create a New Type Map? ..,..,...134 3-25. How Do You create a sQl to java type map entry? 135 3-26. Is There Any Limit on the Number of Connections for JDBC? 145 3-27. How Do You connect as sysdba or sysoper to an oracle Database? 147 3-28. How Do You Check MySQL's/Oracle's JDBC Installation .148 CHAPTEr 4 Making Database Connections Using Data.....153 4-1. How Do You create Connection Using a DataSource object? 153 4-2. How Do You create a data Source object? .....156 4-3. How Do You Create a Data Source object Using Oracle? 156 4-4. How Do You create a Data Source object Using MySQL? 156 4-5. How Do You create a data Source object Using a relational Database(Oracle/MySQL)? 157 4-6. How Do You create a Data Source object Using a DataSource Factory? 160 4-7. What are the DataSource properties? .160 4-8. How Do You Deploy /Register a Data Source 161 4-9. How Do You Use a File-Based System for Registering a DataSource Object? 162 4-10. What Is the Problem with File-Based Data Source Objects? .163 4-11. How Do You Retrieve a Deployed/ Registered Data Source? 164 4-12. How do you obtain a connection with the data Source Without Using JNDI? 4-13. How do You obtain a connection with the data Source Using JNDI? 5203ch00_FM. gxd 8/12/05 12: 17 PM Page x contents CHAPTER 5 Exploring the Resultset Interface 5-1. What is a resultset? 5-2 What is the relationship of resultset to other Classes/Interfaces? 174 5-3. How does the jdK define a resultset? ........,175 5-4. What Kinds of ResultSet Objects Exist? 175 5-5. How Do You Set a Resultset type? .176 5-6. How Do You get a resultset type? 178 5-7. Which ResultSet Types Are Supported by Databases?..,..... 178 5-8. What Is a Resultset Concurrency? 180 5-9. How Do You Set ResultSet Concurrency? .181 5-10. How Do You get ResultSet Concurrency? 5-11. What Is Resultset Holdability? .181 5-12. How Do You set resultset Holdability? .......182 5-13. How Do You Set Resultset Holdability Using the Connection Object? .......182 5-14. How Do You Check Resultset Holdability? 182 5-15. How Do You Get ResultSet Holdability? .......183 5-16. How Do You create and Manipulate Resultset objects? 183 5-17. How do you get rows from a database table 5-18. How Do You get Data from a resultset? 5-19. How Do You Get Rows from a Database Table:?∴·∴ 186 5-20. How Do You get data from a resultset? 187 5-21. How do you determine if a fetched value is null? .191 5-22. How do you get the column names in a result set? 191 5-23. How Do You get the number of rows in a database table? .193 5-24. How do you get blob data from a database table? ....194 5-25. How do you get clob data from a database table? .199 5-26. How Do You Match Using Wildcards in a SQL Statement 200 5-27. How Do You read extract data from a microsoft excel Spreadsheet File? 200 5-28. How Do You Write data to a microsoft Excel Spreadsheet File? 203 5-29. Which Is the Preferred Collection Class to Use for Storing Database result sets? 205 5-30. How Do you retrieve a whole row record of data at once Instead of Calling an Individual resultset. getXXX0 Method for Each Column? 208 5203ch00_FM. gxd 8/12/05 12: 17 PM Page xi CONtentS CHAPTER 6 Working with Scrollable and Updatable Resultset objects 209 6-1. What is a scrollable resultset? 209 6-2. How Do You Determine If a Database Supports Scrollable Resultsets 212 6-3. How Do You create a scrollable resultset? 6-4. How do You determine If a resultset is scrollable? 212 .214 6-5. How do you move the cursor in a scrollable resultset? 214 6-6. How do you get the cursor position in a scrollable result set?. 216 6-7. How Do You Get the Number of rows in a Table Using a Scrollable resultset 217 6-8. How Do You Determine If a Database Supports Updatable Resultsets .218 6-9. How Do You Create an Updatable resultset?........... 219 6-10. How Do You determine If a ResultSet Is Updatable? ..219 6-11. How do You Update a row in a database Table Using an Updatable Result Set? 220 6-12. How Do You Cancel Updates to an Updatable ResultSet? 221 6-13. How Do You Insert a row into a Database Table Using an Updatable Resultset? 222 6-14. HoW Do You delete a Row from a database Table Using an Updatable Resultset? 226 6-15. How Do You refresh a row in an Updatable resultset? .....229 CHAPTER 7 Reading and Writing bLOBs .231 7-1. What ls a blob? 231 7-2. How Do You Define a BLOB Data Type in a Table? 233 7-3. What Are the Restrictions for Using BLOBS? .234 7-4. How Do You create a java. sql Blob Object? .234 7-5. How Do you materialize blob data? 235 7-6. How Do you insert a new record with a blob? 236 7-7. How Do You Select and Display a blob in a JFrame?......... 240 7-8. How Do You delete an Existing blob from the oracle Database? 243 7-9. How Do You delete an Existing bLOB from the mySQL Database? ,,,,,,,,,,,,.245 7-10. How Do You serialize a Java object to the Oracle Database? .246 7-11. How Do You Serialize a Java object to the mySQL Database? 252 7-12. Should You Use bytel or java. sql Blob? Which Has the best Performanc 256

...展开详情
试读 127P JDBC Recipes  原版pdf by Parsian
img
nn123456789

关注 私信 TA的资源

上传资源赚积分,得勋章
    最新推荐
    JDBC Recipes 原版pdf by Parsian 12积分/C币 立即下载
    1/127
    JDBC Recipes  原版pdf by Parsian第1页
    JDBC Recipes  原版pdf by Parsian第2页
    JDBC Recipes  原版pdf by Parsian第3页
    JDBC Recipes  原版pdf by Parsian第4页
    JDBC Recipes  原版pdf by Parsian第5页
    JDBC Recipes  原版pdf by Parsian第6页
    JDBC Recipes  原版pdf by Parsian第7页
    JDBC Recipes  原版pdf by Parsian第8页
    JDBC Recipes  原版pdf by Parsian第9页
    JDBC Recipes  原版pdf by Parsian第10页
    JDBC Recipes  原版pdf by Parsian第11页
    JDBC Recipes  原版pdf by Parsian第12页
    JDBC Recipes  原版pdf by Parsian第13页
    JDBC Recipes  原版pdf by Parsian第14页
    JDBC Recipes  原版pdf by Parsian第15页
    JDBC Recipes  原版pdf by Parsian第16页
    JDBC Recipes  原版pdf by Parsian第17页
    JDBC Recipes  原版pdf by Parsian第18页
    JDBC Recipes  原版pdf by Parsian第19页
    JDBC Recipes  原版pdf by Parsian第20页

    试读已结束,剩余107页未读...

    12积分/C币 立即下载 >