`String query = "select count(book_id) as book_id from library_books_details where book_id = ?";`
PreparedStatement psEnd = collegeCon.prepareStatement(query);
psEnd.setInt(1, bookId);
最佳答案
ResultSet rs = psEnd.executeQuery();
if (rs.next()) {
int count= rs.getInt(1);
System.out.println("Count= " + count);
} else {
System.out.println("error: could not get the record counts");
}
关于java - 我想将计数查询的值分配给整数变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22316611/