IEEE Press
445 Hoes Lane
Piscataway, NJ 08854
IEEE Press Editorial Board
Lajos Hanzo, Editor in Chief
R. Abhari | M. El-Hawary | O. P. Malik |
J. Anderson | B-M. Haemmerli | S. Nahavandi |
G. W. Arnold | M. Lanzerotti | T. Samad |
F. Canavero | D. Jacobson | G. Zobrist |
Kenneth Moore, Director of IEEE Book and Information Services (BIS)
Copyright 2011 by the Institute of Electrical and Electronics Engineers, Inc.
Published by John Wiley & Sons, Inc., Hoboken, New Jersey
Published simultaneously in Canada
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, scanning, or otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4470, or on the web at www.copyright.com. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives or written sales materials. The advice and strategies contained herein may not be suitable for your situation. You should consult with a professional where appropriate. Neither the publisher nor author shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages.
For general information on our other products and services or for technical support, please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic formats. For more information about Wiley products, visit our web site at www.wiley.com.
Library of Congress Cataloging-in-Publication Data:
Bai, Ying, 1956
Practical database programming with Java / Ying Bai.
p. cm.
ISBN 978-0-470-88940-4 (pbk.)
1. Database managementComputer programs. 2. Database design. 3. Java (Computer program language) 4. Computer softwareDevelopment. I. Title.
QA76.9.D3B314 2011
005.13'3dc22
2011009323
obook ISBN 9781118104651
ePDF ISBN 9781118104668
ePub ISBN 9781118104699
This book is dedicated to my wife, Yan Wang, and to my daughter, Xue Bai.
Preface
D atabases have become an integral part of our modern day life. We are an information-driven society. Database technology has a direct impact on our daily lives. Decisions are routinely made by organizations based on the information collected and stored in databases. A record company may decide to market certain albums in selected regions based on the music preference of teenagers. Grocery stores display more popular items at the eye level and reorders are based on the inventories taken at regular intervals. Other examples include patients records in hospitals, customers account information in banks, book orders by the libraries, club memberships, auto part orders, winter cloth stock by department stores, and many others.
In addition to database management systems, in order to effectively apply and implement databases in real industrial or commercial systems, a good graphic user interface (GUI) is needed to enable users to access and manipulate their records or data in databases. NetBeans IDE is an ideal candidate to be selected to provide this GUI functionality. Unlike other programming languages, Java is a kind of language that has advantages, such as easy to earn and easy to be understood, with little learning curves. Beginning from Java 1.0, Sun has integrated a few programming languages, such as C++, JavaFX, and PHP, with some frameworks into dynamic models that make Internet and Web programming easy and simple, and any language integrated in this model can be used to develop professional and efficient Web applications that can be used to communicate with others via Internet.
This book is mainly designed for college students and software programmers who want to develop practical and commercial database programming with Java and relational databases, such as Microsoft Access, SQL Server 2008, and Oracle Database 10 g XE. The book provides a detailed description about the practical considerations and applications in database programming with Java and authentic examples and detailed explanations. More important, a new writing style is developed and implemented in this book, combined with real examples, to provide readers with a clear picture as how to handle the database programming issues in NetBeans IDE environment.
The outstanding features of this book include but are not limited to the following.
A novel writing style is adopted to attract students or beginning programmers who are interested in learning and developing practical database programs, with the hope of avoiding the headaches caused by huge blocks of codes found in traditional database programming books.
A real completed sample database, CSE_DEPT, with three versions (Microsoft Access 2007, SQL Server 2008, and Oracle Database 10 g XE Release 2), is provided and used for the entire book. A step-by-step, detailed description about how to design and build a practical relational database is provided.
Both fundamental and advanced database programming techniques are covered, for the convenience of both beginning students and experienced programmers.
Updated Java database programming techniques, such as Java Persistence API, Java Enterprise Edition 6, JavaServer Pages, JavaServer Faces, and Enterprise Java Beans, are discussed and analyzed with real projects to enable readers to have a clear picture and easy-to-learn path for Java database applications.
More than 30 real sample database programming projects are covered, with detailed illustrations and explanations to help students to understand key techniques and programming technologies.
Three types of popular databases are covered and discussed in detail with practical sample examples: Microsoft Access, SQL Server 2008, and Oracle Database 10 g Express Edition (XE).
The various actual JDBC APIs and JDBC drivers are discussed and presented with real example coding explanations. The working structure and principle of using a JDBC driver to establish a valid database connection, build an SQL statement, and process the query results are introduced in detail with example codes. JDBC RowSet, a useful tool, is also discussed and analyzed with some example codes.
Problems and selected solutions are provided for each chapter to strengthen and improve understanding of the topics.
Power Point teaching slides are also provided to help instructors.
I sincerely hope that this book will be useful to all who adopt it, as a textbook for college students, as well as a reference book for programmers, software engineers, and academic researchers. I would be more than happy to know that you have been able to develop and build professional and practical database applications with the help of this book.