📄 e271. getting the number of rows in a table using a scrollable result set.txt
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -