O'Reilly logo

JavaBeans Unleashed by Rick Leinecker, Dr. Donald Doherty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Retrieving Data Using JDBC

Retrieve data through the JDBC API by implementing the following three steps:

  1. Obtain a driver and establish a connection to a database.

  2. Send an SQL statement to the database and retrieve data.

  3. Assign the data returned from the database to local variables.

The following sections introduce methods you can use to implement each of the three steps used to retrieve data through the JDBC API while you write an example bean, the DatabaseAccess bean, shown in Listing 14.1.

Tip

The DataAccess bean is hard coded to use a JDBC-ODBC Bridge text driver configured with the directory selected containing the database text files. See the previous section, "Setting Up an ODBC Driver," for more information.

Listing 14.1 Source code for ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required