Connection conn = DriverManager.getConnection("jdbc:ucanaccess://" + s1);
PreparedStatement s =conn.prepareStatement("SELECT * FROM Table1", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE, ResultSet.CLOSE_CURSORS_AT_COMMIT);
//ResultSet rs = s.executeQuery();
ResultSet rs = s.executeQuery();
int app1 = 0;
// while (rs.next()) {
rs.updateBoolean("collegato", true);
// if (app1 == app) {
// // rs.updateBoolean("collegato", true);
// }
// app1 = app1 + 1;
// }
rs.close();
我希望能够通过将 collegato
列设置为 true
来更新我的数据库,但它不起作用。
最佳答案
来自 updateBoolean(java.lang.String,boolean) 的文档:
The updater methods do not update the underlying database; instead the updateRow or insertRow methods are called to update the database.
更新ResultSet
后调用rs.updateRow()
,以便更新实际数据库。
关于java - 通过Java代码更新access中的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44264867/