gpt4 book ai didi

java - 检查 MySQL 结果是否返回行

转载 作者:行者123 更新时间:2023-11-29 05:31:55 24 4
gpt4 key购买 nike

我有以下 Java 代码

// SELECT
String stringQuery = "SELECT klucz, itemDATA, itemQTY, itemDUR FROM sellbox WHERE gracz =? "
+ "ORDER BY czas DESC LIMIT 1";

PreparedStatement statement = this.connection.prepareStatement( stringQuery );
statement.setString( 1, playerName );

ResultSet queryResult = statement.executeQuery();
queryResult.first();

如何判断是否返回行?

最佳答案

你可以这样做:

ResultSet queryResult = statement.executeQuery();
if (queryResult.next()) {
// process the data
}

关于java - 检查 MySQL 结果是否返回行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13973786/

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