A database is an organized collection of data. There are many different strategies for organizing data to facilitate easy access and manipulation. A database management system (DBMS) provides mechanisms for storing, organizing, retrieving and modifying data for many users. Database management systems allow for the access and storage of data without concern for the internal representation of data.
Today's most popular database systems are relational databases. A language called SQLpronounced "sequel," or as its individual lettersis the international standard language used almost universally with relational databases to perform queries (i.e., to request information that satisfies given criteria) and to manipulate data. [Note: As you learn about SQL, you will see some authors writing "a SQL statement" (which assumes the pronunciation "sequel") and others writing "an SQL statement" (which assumes that the individual letters are pronounced). In this book we pronounce SQL as "sequel." Thus the article preceding SQL is "a," as in "a SQL statement."]
Some popular relational database management systems (RDBMSs) are Microsoft SQL Server, Oracle, Sybase, IBM DB2, Informix, PostgreSQL and MySQL. In this chapter, we present examples using MySQL, which is located on the CD that accompanies this book and can also be downloaded from dev.mysql.com/downloads/mysql/4.0.html. MySQL is open source and is available for both Windows and Linux. [Note: We discuss basic MySQL features required to execute the examples in this chapter. Please refer to the detailed MySQL documentation for complete information on using MySQL.]
Java programs communicate with databases and manipulate their data using the JDBC™API. A JDBC driver enables Java applications to connect to a database in a particular DBMS and allows programmers to manipulate that database using the JDBC API. JDBC is almost always used with a relational database. However, it can be used with any table-based data source.
Software Engineering Observation 25.1
The separation of the JDBC API from particular database drivers enables developers to change the underlying database without modifying the Java code that accesses the database. |
Most popular database management systems now provide JDBC drivers. There are also many third-party JDBC drivers available. In this chapter, we introduce JDBC and use it to manipulate a MySQL database. The techniques demonstrated here can also be used to manipulate other databases that have JDBC drivers. Check your system's documentation to determine whether your DBMS comes with a JDBC driver. If not, many third-party vendors provide JDBC drivers for a wide variety of databases.
For more information on JDBC, visit
java.sun.com/products/jdbc
This site contains information concerning JDBC, including the JDBC specification, JDBC FAQs, a learning resource center and software downloads. For a list of available JDBC drivers, visit
servlet.java.sun.com/products/jdbc/drivers/
This site provides a search engine to help you locate drivers appropriate to your DBMS.
Introduction to Computers, the Internet and the World Wide Web
Introduction to Java Applications
Introduction to Classes and Objects
Control Statements: Part I
Control Statements: Part 2
Methods: A Deeper Look
Arrays
Classes and Objects: A Deeper Look
Object-Oriented Programming: Inheritance
Object-Oriented Programming: Polymorphism
GUI Components: Part 1
Graphics and Java 2D™
Exception Handling
Files and Streams
Recursion
Searching and Sorting
Data Structures
Generics
Collections
Introduction to Java Applets
Multimedia: Applets and Applications
GUI Components: Part 2
Multithreading
Networking
Accessing Databases with JDBC
Servlets
JavaServer Pages (JSP)
Formatted Output
Strings, Characters and Regular Expressions
Appendix A. Operator Precedence Chart
Appendix B. ASCII Character Set
Appendix C. Keywords and Reserved Words
Appendix D. Primitive Types
Appendix E. (On CD) Number Systems
Appendix F. (On CD) Unicode®
Appendix G. Using the Java API Documentation
Appendix H. (On CD) Creating Documentation with javadoc
Appendix I. (On CD) Bit Manipulation
Appendix J. (On CD) ATM Case Study Code
Appendix K. (On CD) Labeled break and continue Statements
Appendix L. (On CD) UML 2: Additional Diagram Types
Appendix M. (On CD) Design Patterns
Appendix N. Using the Debugger
Inside Back Cover