最後の2日間はこれを把握しようとしていました。ResultSetが終了した後に操作が許可されない
Statement statement = con.createStatement();
String query = "SELECT * FROM sell";
ResultSet rs = query(query);
while (rs.next()){//<--- I get there operation error here
これはクエリメソッドです。
public static ResultSet query(String s) throws SQLException {
try {
if (s.toLowerCase().startsWith("select")) {
if(stm == null) {
createConnection();
}
ResultSet rs = stm.executeQuery(s);
return rs;
} else {
if(stm == null) {
createConnection();
}
stm.executeUpdate(s);
}
return null;
} catch (Exception e) {
e.printStackTrace();
con = null;
stm = null;
}
return null;
}
このエラーを修正するにはどうすればよいですか?
アプリケーションに他のスレッドはありますか? – NPE
実際のエラーを投稿すると便利です。人々は何が起こっているのかの説明なしで問題を本当に助けることはできません。また、 "照会"メソッドで接続やステートメントを作成する場所を確認することもありません。私はcreateConnection()の呼び出しを見ますが、そこには割り当てはなく、そのメソッドの中には "stm"の割り当てもありません。 – Matt