Cannot find symbol from ResultSet JDBC [duplicate]

二次信任 提交于 2019-12-26 14:36:45

问题


I'm getting a cannot find symbol error and it points to the period right in rs.getChars(1) This code is all within a try{}.

There are three columns in the view table, title, item_id, and name. I'm just trying to query it but get a cannot find symbol on the line inside the start of the while loop.

PreparedStatement pstmt= 
conn.prepareStatement("SELECT * FROM Film_Sound_Track");
ResultSet rs = pstmt.getResultSet();

while(rs.next()){
    char item_id = rs.getChars(1);
}

rs.close();
pstmt.close();

回答1:


java.sql.ResultSet does not have a method getChars. You could use the getString method to retrieve a String and then extract the char from it:

char item_id = rs.getString(1).charAt(0);


来源:https://stackoverflow.com/questions/26917853/cannot-find-symbol-from-resultset-jdbc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!