| This Chapter | |
| - | Chapter 22: Java Database Connectivity |
| - | Introduction to JDBC |
| - | Four Steps to Data Access |
| - | Reading Metadata |
| - | The SQLTool Example |
| - | Summary |
| - | Questions |
Even though Java is an object-oriented programming language, data and object state are commonly stored in relational databases. Accessing the database and manipulating data in it therefore is a very important topic of discussion.
There are many brands of databases. To name a few: Oracle, Sybase, Microsoft SQL Server, Microsoft Access, PostgreSQL, and MySQL. Every database server allows access through a proprietary protocol. As such, accessing different databases require different skills. Fortunately for Java programmers, Java Database Connectivity (JDBC) is available to enable easy database and data manipulation. JDBC provides a uniform way of accessing different databases. http://java.sun.com/products/jdbc/index.html is the official Web site for the JDBC technology.
Java 5 includes the version 3.0 of the JDBC. At the time of writing version 4.0 was in the making. The JDBC Application Programming Interface (API) has two parts: the JDBC Core API and the JDBC Optional Package API. The Core part is good for basic database programming, such as creating tables, retrieving data from single and multiple tables, storing data in a table, updating and deleting data, and others. The classes and interfaces in the Core part are members of the java.sql package. The JDBC Optional Package API is specified in the javax.sql package and supports advanced features such as connection pooling, support for Java Naming and Directory Interface (JNDI), distributed transactions, etc. This book only deals with the Core part.
Note
The discussion of JDBC in this book assumes you have basic knowledge of SQL.