Solved

java.sql.Statement lifecycle

Posted on 2001-09-18
4
245 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
reverse digits of a number using for loop 5 52
type mismatch (Object[] to double[] 4 33
null output 3 35
Java class and jar 3 20
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…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This video teaches viewers about errors in exception handling.

839 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