PreparedStatement
Hi,
I have a PreparedStatement in a method, when i go out of that method, does the PreparedStatement closed automatically or I have close it manually myself?
The reason I didn't close is because i have to return the result. If i close the preparedstatement, then my resultset will be closed too and when go back to caller, i can't output the result.
In this case, what would be the suitable solution?
Please advise.
Thank you.
[465 byte] By [
jbchurna] at [2007-10-2 7:30:42]

> I have a PreparedStatement in a method, when i go out
> of that method, does the PreparedStatement closed
> automatically or I have close it manually myself?
PreparedStatement is not closed automatically.
> The reason I didn't close is because i have to return
> the result. If i close the preparedstatement, then my
> resultset will be closed too and when go back to
> caller, i can't output the result.
If you want to return the result, you should not be returning the ResultSet. Read through the resultset and store the data in a List.