O'Reilly logo

Apache Derby—Off to the Races: Includes Details of IBM® Cloudscape™ by Dan Scott, George Baklarz, Paul C. Zikopoulos

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 Query Results

At some point an application will want to retrieve some data from the database. The method that returns an answer set is executeQuery(). This method takes an SQL string as its argument and attempts to create a result set from the database.

ResultSet rs = null;
rs = s.executeQuery("SELECT Production_Title FROM Productions");

A result set will contain a number of rows, with each row containing the columns that are specified in the select list. A result set is very similar to an array of records. For instance, the previous example returns 10 rows, but with only one column (Production_Title) being returned from the Productions table.

To retrieve the values from the result set, a simple while loop can be created to process ...

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