gpt4 book ai didi

java - 我想将计数查询的值分配给整数变量

转载 作者:行者123 更新时间:2023-11-29 08:08:06 25 4
gpt4 key购买 nike

`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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com