I am using JDBC to retrieve data from a database. I understand that a Statement needs to be closed after it is used. However, I keep run into the same error telling me that no operation is allowed after the statement is closed. The structure of my code is like
public void foo() {
Statement;
try {
} catch{
}
Statement.close();
}
In my code, I need to call this function repeatedly. I was wondering where to close the Statement.
Thanks
According to the Javadocs:
In your method which you say you call repeatedly you are calling
Statement.close()which means that you can only use it once since after the first call you Statement is closed and cannot be used anymore.It would be nice to see some of your code if you want a better answer