To understand how relational databases store information
To learn how to query a database with the Structured Query Language (SQL)
To connect to a database with Java Database Connectivity (JDBC)
To write database programs that insert, update, and query data in a relational database
In Chapter 19 you saw how to store data in a file. When you store data, you will want to be able to add more data items, remove data, change data items, and find items that match certain criteria. However, if you have a lot of data, it can be difficult to carry out these operations quickly and efficiently. Because data storage is such a common task, special database management systems (DBMS) have been invented that let the programmer think in terms of the data rather than file storage. In this chapter you will learn how to use SQL, the Structured Query Language, to query and update information in a relational database, and how to access database information from Java programs.
A relational database stores information in tables. Figure 1 shows a typical table. As you can see, each row in this table corresponds to a product. The column headerscorrespond to attributes of the product: the product code, description, and unit price. Note that all items in a particular column have the same type: product codes and descriptions are strings, unit prices are floating-point numbers. The allowable column types differ somewhat from ...