Return type for inline methods that query databases: java.sql.ResultSet object

You can use the Data interface's queryResults() method to return the results of a query in a java.sql.ResultSet object.
java.sql.ResultSet queryResults(java.lang.String sql, Object... parameters)

Returned ResultSet objects are read-only. Also, you cannot access the Statement object that is associated with a ResultSet object.

Example

You could access all columns of all rows of the HRDEPT.EMPLOYEE table as a ResultSet object by using code that looks like this:

Connection con = DriverManager.getConnection(...);                                                    1 
Data db = DataFactory.getData(con);                                                                   2 
java.sql.ResultSet empResult = db.queryResults(
  "SELECT EMPNO, FIRSTNME, MIDINIT, LASTNAME, WORKDEPT, PHONENO, HIREDATE FROM HRDept.Employee" );    3 

The code performs the following steps:

  1. Create a connection to the database.
  2. Create an instance of an implementation of the Data interface.
  3. Call the queryResults() method, passing the result of the SELECT statement into a ResultSet object that is assigned to the reference variable empResult.

Feedback