Alex Rivera | Logout

When should a java PreparedStatement be closed?

Asked 2011-06-15T04:35:04.197
9

In the tutorial "Using Prepared Statements" it states that they should always be closed. Suppose I have a function

getPrice() {
}

that I expect to be called multiple times per second. Should this method be opening and closing the PreparedStatement with every single method call? This seems like a lot of overhead.

Edit
Report

1 Answer

0

I think that, after every database interaction, every component like statement, resultset must be closed, except for connection, if u tend to perform more operation.

And there is no need to worry, if you are creting the prepared statement again and again, because as you will be using the same statement again and again, there wont be any performannce issue.

answered 2011-06-15T05:35:11.263

Your Answer