JDBC 更新数据结构集操作

xiaoxiao2021-02-27  876

查询结果集是否支持更新操作

try {         DatabaseMetaData dmd = connection.getMetaData();         if (dmd.supportsResultSetConcurrency(             ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE)) {             // Updatable result sets are supported         } else {             // Updatable result sets are not supported         }     } catch (SQLException e) {     }

创建一个可以更新的结果集

try {         // Create a statement that will return updatable result sets         Statement stmt = connection.createStatement(             ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);             // Primary key col_string must be specified so that the result set is updatable         ResultSet resultSet = stmt.executeQuery("SELECT col_string FROM my_table");     } catch (SQLException e) {     }
转载请注明原文地址: https://www.6miu.com/read-68.html

最新回复(0)