Example usage for com.google.gwt.gears.client.database ResultSet close

List of usage examples for com.google.gwt.gears.client.database ResultSet close

Introduction

In this page you can find the example usage for com.google.gwt.gears.client.database ResultSet close.

Prototype

public void close() throws DatabaseException 

Source Link

Document

Releases the state associated with this ResultSet .

Usage

From source file:com.google.gwt.gears.sample.database.client.DatabaseDemo.java

License:Apache License

/**
 * Fill the labels with the phrases from the database.
 */// ww w . j  a  v  a2s  .  c o  m
private void displayRecentPhrases() {
    try {
        ResultSet rs = db.execute("SELECT * FROM Phrases ORDER BY Id DESC");
        int i;

        for (i = 1; rs.isValidRow(); ++i, rs.next()) {
            if (i <= NUM_SAVED_ROWS) {
                dataTable.setText(i, 0, rs.getFieldAsString(0));
                dataTable.setText(i, 1, rs.getFieldAsString(1));
                dataTable.setText(i, 2, new Date(rs.getFieldAsLong(2)).toString());
            } else {
                db.execute("DELETE FROM Phrases WHERE Id = ?", new String[] { rs.getFieldAsString(0) });
            }
        }
        // If a phrase has been removed, clear the label.
        for (; i <= NUM_SAVED_ROWS; i++) {
            for (int j = 0; j < NUM_DATA_TABLE_COLUMNS; j++) {
                dataTable.clearCell(i, j);
            }
        }
        rs.close();
    } catch (DatabaseException e) {
        Window.alert(e.toString());
    }
}