Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP Sybase SQL Anywhere 16.0 » UltraLite - Java Programming » UltraLiteJ application development » Quick start guide to schema operations and data management


Row data retrieval

Retrieve row data from a table by performing the following general tasks:

  1. Construct a SELECT SQL statement in a String variable.

  2. Create a PreparedStatement object by passing the String variable to the Connection.prepareStatement method.

  3. Call the PreparedStatement.executeQuery method to assign the query results to a ResultSet object.

  4. Traverse through the ResultSet object using the navigational methods to retrieve the row data.

    The following navigational methods can be used to traverse a result set:

    • afterLast1   Position immediately after the last row.

    • beforeFirst1   Position immediately before the first row.

    • first1   Move to the first row.

    • last1   Move to the last row.

    • next   Move to the next row.

    • previous   Move to the previous row.

    • relative(offset)1   Move a specified number of rows relative to the current row, as specified by the signed offset value. Positive offset values move forward in the result set, relative to the current pointer position in the result set. Negative offset values move backward in the result set. An offset value of zero does not move the current location, but allows you to repopulate the row buffer.

    1 This method is not supported for UltraLite Java edition databases.

  5. Close the ResultSet and PreparedStatement objects to free resources.

 See also