SQL语句:
select * from usrpsw limit 0, 5
表格结构是
res是ResultSet的对象
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
res = stmt.executeQuery(sql);
res.first();
res.updateString( 1, "PR-10004 ");
res.updateRow();
结果如图:
参考:
http://www.exampledepot.com/egs/java.sql/UpdateRow.html
try {
// Create an updatable result set
Statement stmt = connection.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet resultSet = stmt.executeQuery("SELECT * FROM my_table");
// Move cursor to the row to update
resultSet.first();
// Update the value of column col_string on that row
resultSet.updateString("col_string", "new data");
// Update the row; if auto-commit is enabled, update is committed
resultSet.updateRow();
} catch (SQLException e) {
}