In JDBC, can I use single Statement
object to call executeQuery(\"\")
multiple times? Is it safe? Or should I close the statement object after each que
Yes you can re-use a Statement
(specifically a PreparedStatement
) and should do so in general with JDBC. It would be inefficient & bad style if you didn't re-use your statement and immediately created another identical Statement
object. As far as closing it, it would be appropriate to close it in a finally block, just as you are in this snippet.
For an example of what you're asking check out this link: jOOq Docs