e275. updating a row in a database table using an updatable result set.txt

来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 21 行

TXT
21
字号
Updating the current row of an updatable result set involves calling ResultSet.updateXXX() methods followed by a call to updateRow(). 
See also e273 Creating an Updatable Result Set. 

    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) {
    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?