db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Cecchet <m...@frogthinker.org>
Subject Re: Why close ResultSet & PreparedStatement?
Date Sat, 29 Nov 2008 22:45:29 GMT
derby@segel.com wrote:
>> Amir Michail wrote:
>>     
>>> Hi,
>>>
>>> Is there any point in calling the close method on ResultSet and the
>>> close method of PreparedStatement?
>>>
>>> Amir
>>>       
>> You might later change the database to one where it matters much more.
>>
>> Mark Thornton
>>     
>
> Huh?
>
> I'm sorry but your answer doesn't make any sense.
>   
Mark answer made a lot of sense. Things that may not have a side effect 
with Derby (especially in embedded mode) can have a significant effect 
with other databases. Try to leave ResultSets and PreparedStatements 
open with Oracle and we'll see how far you go.
> To answer Amir's question... you close the ResultSet and the
> PreparedStatements to remove any overhead as a result of their
> instantiation.
>
> Actually its pretty rare that you want to close the prepared statement since
> one would use a prepared statement for the life of the application/service.
> (The point of a prepared statement is that you use the statement once and
> you use it over and over ...)
>   
Looks like you have never done batch updates.
Note that a PreparedStatement is attached to a connection, so if you are 
using connection pooling, keeping the same PreparedStatement throughout 
the lifetime of the application will certainly interfere with the 
purpose of the connection pooling.

My 2 cents
Emmanuel

-- 
Emmanuel Cecchet
FTO @ Frog Thinker 
Open Source Development & Consulting
--
Web: http://www.frogthinker.org
email: manu@frogthinker.org
Skype: emmanuel_cecchet


Mime
View raw message