如何在Java中使用executeQuery()获取返回值? [英] How to get the return with executeQuery() in Java?
本文介绍了如何在Java中使用executeQuery()获取返回值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个代码;
String sql = "UPDATE Players SET Losses=Losses+1 WHERE UUID='" + p.getUniqueId() + "';";
stmt.executeUpdate(sql);
如何获取当前 Losses
一个特定的玩家p
?
How can I get the current Losses
for a specific Player p
?
推荐答案
以下。看起来很琐碎,猜测你是一个绝对的初学者。
You can get the losses like the following. Seems really trivial, guess you are an absolute beginner.
String sql = "SELECT Losses FROM Players WHERE UUID='" + p.getUniqueId() + "';";
ResultSet rs = stmt.executeQuery(sql);
int losses = -1;
if(rs.next()) {
losses = rs.getInt("Losses");
}
这篇关于如何在Java中使用executeQuery()获取返回值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文