RowSet: setString(int parameterIndex, String x) : RowSet « javax.sql « Java by API






RowSet: setString(int parameterIndex, String x)

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.RowSet: setCommand(String cmd)
2.RowSet: setPassword(String password)
3.RowSet: setUsername(String name)
4.RowSet: setUrl(String url)