簡體   English   中英

檢查Java數據庫表中是否存在word

[英]Check if word exists in within a database table in Java

因此,我有一個數據庫,其中有一個包含兩列的表:rightWord和rongeWord。 我希望在rightWord值等於Java中聲明的變量時選擇rightWord值。 到目前為止,我有以下代碼:

SELECT rightWord FROM dictionaryTable WHERE wrongWord = (?)

existingKeywords.next();
String rightWord = existsingKeywords.getString("rightWord");

那行得通,並且當rightWord等於Java變量時,我能夠在rightWord列中獲取第一個值。 現在,如何檢查錯字列中的任何值是否與Java變量不匹配? 我在for循環中有上述代碼,並且java變量的值每次都不同。

請幫忙。 謝謝!

假設existingKeywordsResultSet是您的ResultSet 沒有值時, next()函數將返回false

典型用法:

 if (existingKeywords.next()) {
    String rightWord = existingKeywords.getString("rightWord");
 } else {
    // no right word...
 }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM