Hi all. I am trying to write a code in which i want to manage stock by fetching data from purchase table. I have the following code and it gave me Operation Not allowed after resultset is closed. I haven't closed it at all!. Please help!
Hi Pranit,
In JDBC a ResultSet associated with a Statement is closed as soon as we associate another ResultSet to the same Statement before closing the previous ResultSet.
I hope now you understand the problem in the code and find a solution and please post the solution if you get.
If you do not understand the problem even now we will provide the solution.
Tapas Chand wrote:Hi Pranit,
In JDBC a ResultSet associated with a Statement is closed as soon as we associate another ResultSet to the same Statement before closing the previous ResultSet.
I hope now you understand the problem in the code and find a solution and please post the solution if you get.
If you do not understand the problem even now we will provide the solution.
On a separate note, the following things will make the program a little better.
1. You are using just 2 fields from your first ResultSet. So do not select all the fields, only select required fields. This will improve network traffic.
2. No need to call ResultSet.beforeFirst() before calling ResultSet.next(). Program will behave the same if you do not call ResultSet.beforeFirst() in this case.
3. In second ResultSet, I assume, you are expecting only 1 record from DB. If so, use if statement in place of while loop.