Solved

java.sql.Statement lifecycle

Posted on 2001-09-18
4
241 Views
Last Modified: 2006-11-17
a Connection object creates a Statement object (connection.createStatement())

but what if that connection later dies (say the database falls over)  what happens to the Statement object?
will it stay around to cause trouble or does it dissapear along with its connection?

regards,
John

JohnSenford@hotmail.com
0
Comment
Question by:johnsenford
4 Comments
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 6490066
It should get closed, when the connection is closed.
But you really should close statements once you're done with them, as well as closing ResultSet's.
0
 

Author Comment

by:johnsenford
ID: 6490324
of course you should close them, but I was thinking of the scenario whereby you didn't anticipate the connection being closed in the first place (it wasn't an explicit closure)
0
 

Expert Comment

by:ManojShetty
ID: 6491001
If a connection is closed then automatically all resultsets & statements associated with the connection also get closed.
0
 
LVL 20

Expert Comment

by:Venabili
ID: 8916416
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Points for objects

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Venabili
EE Cleanup Volunteer
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This video teaches viewers about errors in exception handling.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now