So I have a database, within which there is a table with two columns: rightWord and wrongWord. I wish to select the rightWord value when the wrongWord value is equal to a variable declared in Java. I have the following code so far:
SELECT rightWord FROM dictionaryTable WHERE wrongWord = (?)
existingKeywords.next();
String rightWord = existsingKeywords.getString("rightWord");
That works and I am able to get the first value in rightWord column when wrongWord equals the Java variable. Now, how can I check if the any of the values in the wrongWord column does not match the Java variab开发者_Python百科le? I have the above code in a for loop, and the value of the java variable is different every time.
Please help. Thanks!
Assuming existingKeywords
is your ResultSet
. The next()
function will return false
when there is no value.
Typical usage:
if (existingKeywords.next()) {
String rightWord = existingKeywords.getString("rightWord");
} else {
// no right word...
}
精彩评论