February 2014
Beginner
1248 pages
62h 25m
English
The example of Fig. 24.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.
Lines 3–8 import the JDBC interfaces and classes from package java.sql used in this program. Method main (lines 12–48) connects to the books database, queries the database, displays the query result and closes the database connection. Line 14 declares a String constant for the database URL. This identifies the name of the database to connect to, as well as information about the protocol used by ...
Read now
Unlock full access