清單 4. 一個讀取數據的完整示例 // First, get all rows meeting the criterion RowSet rs = table.getRows( "id<103" ); // Iterate through the set for (int i=0; i<rs.length(); ++i) { // Grab each row in turn Row row = rs.get( i ); // Get and PRint the value of the "name" field String name = row.get( "name" ); System.out.println( "Name: "+name ); }
清單 5. 重新創建一個 Row // Create an empty row object Row row = new Row(); // Fill it up with data row.put( "id", "200" ); row.put( "name", "Joey Capellino" );
或者,您可以修改一個以前曾經從數據庫中讀取的一個現有的行,如清單 6 所示。
清單 6. 修改現有的 Row // Grab a row from the database Row row = table.getRow( someConditions ); // Change some or all of the fields row.put( "name", "Joey Capellino" );