2016-03-02 82 views
-1
PreparedStatement codePull = (PreparedStatement) con.prepareStatement("SELECT tanCode FROM `tancodes` WHERE (tanIndex= "+Tindex+")"); 
     ResultSet DbTcode = codePull.executeQuery(); 
     String answer = DbTcode.getString(""); 
     return answer; 

這是我使用的代碼,但問題是,我得到一個錯誤,指出: ERR:值java.sql.SQLException:列「」未找到。錯誤的MySQL

但我可以看到它確實存在於表中!

關於如何解決它的任何想法?

回答

0

嘗試寫這樣的查詢:

"SELECT tanCode FROM tancodes WHERE tanIndex= '"+Tindex+"'" 

這裏寫列的名稱,如:

DbTcode.getString("tanCode");// for example 

因爲"it is: "它不是列的名稱。

+0

//我試過了,但發生了同樣的錯誤! –

+0

哦,我非常感謝:D –