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

标签 java database

 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/

相关文章:

java - Firebase JSON 到 Arraylist 内的 Arraylist 存在对象问题

java - 索引越界尝试通过任务栏图标启用最小化

MySQL - 建议链接多个表 - 这是正确的吗?

java - 将对象保存到数据库时使用hibernate

java - 将复杂的map和list结构转换为JSON

java - 使用 Stringbuilder 的神秘空白

java - 从java文件中删除注释并维护文件结构

javascript - PHP中的JSON无法传输字符串

php - 类 DatabaseSeeder 不存在......播种机在 laravel 中不工作

database - 是否有 postgresql 的数据可视化工具也能够显示模式间关系?