e271. getting the number of rows in a table using a scrollable result set.txt
来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 16 行
TXT
16 行
This example gets the number of rows in a scrollable result set by moving the cursor to the last row of the result set and then calling ResultSet.getRow().
try {
// Create a scrollable result set
Statement stmt = connection.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet resultSet = stmt.executeQuery("SELECT * FROM my_table");
// Move to the end of the result set
resultSet.last();
// Get the row number of the last row which is also the row count
int rowCount = resultSet.getRow();
} catch (SQLException e) {
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?