Like this article? We recommend
Querying the Database
To query the database, you can instantiate a ResultSet object, as illustrated in Listing 3.
Listing 3 Creating a ResultSet object
ResultSet rs1 = s.executeQuery( "SELECT MACHINE, VENDOR, MODEL, COMPONENT_ID FROM " + PrincipalTable);
The next step is to look inside the ResultSet object.
Remember that he code inside the parentheses in Listing 3 is just an SQL select statement. As the Derby reference manual describes it: A select statement returns a ResultSet.
Another important database item is a cursor, which is a pointer to a specific row in a ResultSet object. In Java applications, all ResultSet objects are cursors.
So, the next step is pulling some data out of the ResultSet object.