?
Solved

java.sql.Statement lifecycle

Posted on 2001-09-18
4
Medium Priority
?
252 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 92

Accepted Solution

by:
objects earned 200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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…
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…
Suggested Courses
Course of the Month10 days, 19 hours left to enroll

770 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