Hi,
It would be the same thing closing a Connection right? Closing a connection closes implicitly all the statements and resultset to it connected right?
Thanks in advance.
About Question enthuware.ocpjp.v7.2.1155 :
Moderator: admin
-
- Posts: 132
- Joined: Thu May 16, 2013 9:23 am
- Contact:
-
- Posts: 132
- Joined: Thu May 16, 2013 9:23 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1155 :
UPDATE: my concern is about the answer of this thread of Marko Topolonik at the bottom page:
http://stackoverflow.com/questions/1402 ... -resultset
Thanks in advance.
The_Nick.
http://stackoverflow.com/questions/1402 ... -resultset
resource leaks? So actually closing the connection does not guarantee anything right?The details are ultimately down to each JDBC driver implementation; however, once a connection to the database is closed, everything related to it is disposed at the DB side, so there is nothing much the client side can do but auto-close the objects representing these resources.
You never know in what ways the databeses/drivers could be broken (there may be resource leaks, for example), therefore the best practice recommendation is to close everything explicitly.
share|improve this answer
answered Dec 24 '12 at 17:55
Marko Topolnik
Thanks in advance.
The_Nick.
-
- Site Admin
- Posts: 10066
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1155 :
Well, closing the connection closes database connection. That is guaranteed. Since Statement and ResultSet are tied to a connection, they will be useless after the connection is closed.
I am not sure what resource leaks the poster is talking about. But anything that is not in the Java world cannot be guaranteed by the JVM. After all, the database is a third party application, beyond the control of JVM. You can potentially write a database with resource leaks and JVM can't do anything about it.
HTH,
Paul.
I am not sure what resource leaks the poster is talking about. But anything that is not in the Java world cannot be guaranteed by the JVM. After all, the database is a third party application, beyond the control of JVM. You can potentially write a database with resource leaks and JVM can't do anything about it.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 19
- Joined: Mon Sep 01, 2014 9:45 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1155 :
Have problem with this question. I had a nasty surprise with the outcome. The database were I test all the code HSQLDB and closing statement at line 11 not throwing any Exceptions, even If I close the connection on the same line. Not shure about any other databases. But seems like the close method is DB related or in case I have same question on the exam am I need to pick the option with exception since JavaDoc says so? Many thanks.
-
- Site Admin
- Posts: 10066
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1155 :
Yes, you should rely on what the JavaDoc says because implementations may not always be compliant.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 224 guests