Solved

java.sql.Statement lifecycle

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
difference of if loops 23 68
ejb mdb examples 1 19
Bot application - advice 3 58
batch vs regular insert in spring DAO 2 20
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

679 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