问题
I want to use RowSet Interface implement update,But I meet some error.
I’ve tried on following code:
// Load the JDBC driver
Class.forName("com.mysql.cj.jdbc.Driver");
System.out.println("Driver loaded");
RowSetFactory rsFactory = RowSetProvider.newFactory();
JdbcRowSet rowSet = rsFactory.createJdbcRowSet();
rowSet.setUrl(DATABASE_URL);
rowSet.setUsername(USERNAME);
rowSet.setPassword(PASSWORD);
// make rowset updateable
rowSet.setReadOnly(false);
rowSet.setType(ResultSet.TYPE_SCROLL_INSENSITIVE);
rowSet.setConcurrency(ResultSet.CONCUR_UPDATABLE);
rowSet.setCommand("Select * from money");
rowSet.execute();
rowSet.absolute(3);
rowSet.updateInt("balance", parseIntBalance); //update third rows balance label to 5000
rowSet.updateRow();
Following is error message:
java.sql.SQLException: ResultSet is not updatable
at com.sun.rowset.JdbcRowSetImpl.checkTypeConcurrency(JdbcRowSetImpl.java:4139)
at com.sun.rowset.JdbcRowSetImpl.updateInt(JdbcRowSetImpl.java:2306)
at com.sun.rowset.JdbcRowSetImpl.updateInt(JdbcRowSetImpl.java:2735)
来源:https://stackoverflow.com/questions/56090869/java-sql-sqlexception-resultset-is-not-updatable-with-jdbcrowset