Re: Will calling "close()" on a "java.sql.Connection" really close associated resources?
- From: Arne Vajhøj <arne@xxxxxxxxxx>
- Date: Sun, 19 Jul 2009 15:04:18 -0400
Kevin McMurtrie wrote:
In article <4a612f53$0$48234$14726298@xxxxxxxxxxxxxxx>,
Arne Vajhøj <arne@xxxxxxxxxx> wrote:
Lothar Kimmeringer wrote:david.karr wrote:It could happen.The thing is, theThe problem is that documentation and reality are not always the
javadoc for the "close()" method says this:
"Releases this Connection object's database and JDBC resources
immediately instead of waiting for them to be automatically released.
"
same and if you have to solve the problem, that resources are
actually not closed you don't care what might be "correct" and
you close the reosurces by yourself to make sure.
JDBC-drivers are implemented by third-parties, so with every
new database you can run into different problems leading to
constructs like these.
But do you have any example of drivers not implementing it
correctly?
Connection pools may not be able to close DB resources automatically. Doing so requires proxying a lot of complicated JDBC calls and trying to match the internal state of the driver. That's not easy since the definition and lifespan of a resource varies by driver and whether or not the connection is full-duplex.
????
The JDBC spec very clearly states what a pooled connection driver
has to do in this regard and it is rather simple to implement.
(see previous post that quotes the JDBC spec)
It's best to have a try/finally to manually close resources.
Everybody agrees that connections should be closed. The topic
is whether statements (and result sets) should be explicit closed
or not.
There are no difference in the specs regarding this for non pooled
and pooled connections.
Even if there's no pooling now, it may be a required feature eventually. Pooling can improve small query performance by 3x in simple systems.
With a sufficient broad definition of query performance absolutely
(it is connection establishment overhead that is removed).
Arne
.
- References:
- Will calling "close()" on a "java.sql.Connection" really close associated resources?
- From: david.karr
- Re: Will calling "close()" on a "java.sql.Connection" really close associated resources?
- From: Lothar Kimmeringer
- Re: Will calling "close()" on a "java.sql.Connection" really close associated resources?
- From: Arne Vajhøj
- Re: Will calling "close()" on a "java.sql.Connection" really close associated resources?
- From: Kevin McMurtrie
- Will calling "close()" on a "java.sql.Connection" really close associated resources?
- Prev by Date: Re: Java language and library suggestions
- Next by Date: Re: SCJP console tutorial
- Previous by thread: Re: Will calling "close()" on a "java.sql.Connection" really close associated resources?
- Next by thread: ♡.◑▂◐Wholesale (WWW.fjrjtrade.COM) Red monkey Jeans,BBC jeans,evisu jeans,bape jeans
- Index(es):
Relevant Pages
|