gpt4 book ai didi

Java,MySQL - 线程异常 "main"java.sql.SQLException : Operation not allowed after ResultSet closed

转载 作者:行者123 更新时间:2023-11-28 23:23:05 27 4
gpt4 key购买 nike

<分区>

我正在尝试获取 ResultSet 的第一个元素。为什么我会收到此错误

public ResultSet executeSearch(String q){
openConnection();
ResultSet resultSet = null;
try{
Statement statement = connection.createStatement();
resultSet = statement.executeQuery(q);
closeConnection();
return resultSet;
}
catch (Exception e){
JOptionPane.showMessageDialog(null, e.getMessage());
}
finally {
closeConnection();
}
return resultSet;
}

public int getAddressID(String city) throws SQLException{
String q = "SELECT PK_ADDRESS_ID FROM tbl_addresses WHERE city =" + "\'"+ city + "\';";
System.out.println(q);
ResultSet rs = executeSearch(q);
int i = 0;
if (rs.next()){
i = rs.getInt(1);
};
return i;
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com