Re: Will calling "close()" on a "java.sql.Connection" really close associated resources?



Kevin McMurtrie wrote:
In article <4a612f53$0$48234$14726298@xxxxxxxxxxxxxxx>,
Arne Vajhøj <arne@xxxxxxxxxx> wrote:
Lothar Kimmeringer wrote:
david.karr wrote:
The thing is, 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.
"
The problem is that documentation and reality are not always the
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.
It could happen.

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
.



Relevant Pages

  • Re: JDBC Connection Help
    ... database in VBS. ... I have the correct driver 0jdbc.jar which from what I can tell contains ... trying to establish a JDBC connection. ...
    (microsoft.public.scripting.vbscript)
  • Re: DBC Connection - Protocol error when execute Select
    ... I tested the Program which is shown at the Community wiki:http://community.ingres.com/wiki/Java_Example ... Connection aborted due to communications ... I used JDBC - Driver Version 3.2 with Ingres Release 9.2.0 but this ... JDBC - Version works works only with Version 9.1.0. ...
    (comp.databases.ingres)
  • Re: Jdbc connect to plain text
    ... u can create a DSN or DSN connection with the text file using the driver ... > "JDBC technology is an API that lets you access virtually any tabular ...
    (comp.lang.java.help)
  • Re: Reestablishing a db connection after a network failure
    ... will instruct the driver to attempt to reconnect automatically. ... The MySQL JDBC ... whether it handles all cases of connection interruption. ... Implement the Data Access Object pattern, ...
    (comp.lang.java.programmer)
  • Re: Reestablishing a db connection after a network failure
    ... will instruct the driver to attempt to reconnect automatically. ... The MySQL JDBC ... whether it handles all cases of connection interruption. ... Implement the Data Access Object pattern, ...
    (comp.lang.java.databases)