28.8 Manipulating Databases with JDBC

This section presents two examples. The first introduces how to connect to a database and query it. The second demonstrates how to display the result of the query in a JTable.

28.8.1 Connecting to and Querying a Database

The example of Fig. 28.23 performs a simple query on the books database that retrieves the entire Authors table and displays the data. The program illustrates connecting to the database, querying the database and processing the result. The discussion that follows presents the key JDBC aspects of the program. [Note: Sections 28.528.7 demonstrate how to start the MySQL server, configure a user account and create the books database. These steps must be performed before executing the program ...

Get Java How to Program (early objects), 9/e now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.