CachedRowSet: acceptChanges() : CacheRowSet « javax.sql.rowset « Java by API






CachedRowSet: acceptChanges()

 
import javax.sql.rowset.CachedRowSet;

public class Main {
  

  public static void main(String[] args) throws Exception {
    CachedRowSet rs;
    String ROWSET_IMPL_CLASS = "com.sun.rowset.CachedRowSetImpl";
    
    
    Class c = Class.forName(ROWSET_IMPL_CLASS);
    rs = (CachedRowSet) c.newInstance();

    rs.setUrl("jdbc:postgresql:dbname");
    rs.setUsername("username");
    rs.setPassword("password");

    rs.setCommand("select * from members where name like ?");
    rs.setString(1, "I%");

    rs.execute();

    while (rs.next()) {
      if (rs.getInt("id") == 42) {
        rs.setString(1, "newString");
        rs.updateRow(); // Normal JDBC

        rs.acceptChanges();
      }
    }
    rs.close();
  }
}

           
         
  








Related examples in the same category

1.com.sun.rowset.CachedRowSetImpl
2.CachedRowSet: close()
3.CachedRowSet: execute()
4.CachedRowSet: setCommand(String cmd)
5.CachedRowSet: setMetaData(RowSetMetaData md)
6.CachedRowSet: setPassword(String password)
7.CachedRowSet: setString(int parameterIndex, String x)
8.CachedRowSet: setUsername(String name)
9.CachedRowSet: setUrl(String url)
10.CachedRowSet: updateRow()