gpt4 book ai didi

java - 通过Java代码更新access中的列

转载 作者:太空宇宙 更新时间:2023-11-04 11:26:50 25 4
gpt4 key购买 nike

 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com