清单 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" );