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

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

Introduction

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

Prototype

public long getFieldAsLong(int fieldIndex) throws DatabaseException 

Source Link

Document

Retrieves the value of the field at fieldIndex as a long.

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.
 *///from ww w .j av  a  2s.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());
    }
}