This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Statement is closed? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Statement is closed?" Watch "Statement is closed?" New topic
Author

Statement is closed?

Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
I have numerous statement objects and result sets that are defined in different methods in one class. I am closing each statement object in a finally block at the end of each method. Now I keep getting "Statement is closed" error when I try to run my app. What is going on? If I am creating a new Statement object whenever that method is run, why is it telling me that it is closed? It doesn't get closed until it's done running through the method, right?
Here's some code...


Any ideas?
Thanks!
Blake Minghelli
Ranch Hand

Joined: Sep 13, 2002
Posts: 331
From you code sample:

Is con a java.sql.Connection object? If so, is that just a typo in your post, do you mean con.createStatement();??? If con is not a java.sql.Connection object, then I think I need to see the getStatement() method code.
Other than the con.getStatement(), I don't see anything wrong.


Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
Sorry! I have an SQLConnection class that is creating the statement. Here it is:

Does that help?
Thanks again!
Blake Minghelli
Ranch Hand

Joined: Sep 13, 2002
Posts: 331
Argh.... for some reason I can't see your initial post now. Can you repost the original offending method that was causing the exception and specifically which line? I don't see anything wrong with your SQLConnection class.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Statement is closed?
 
Similar Threads
More Simplified version of the question bellow !
multiple processes... only want one
junk characters for byte charset
make a button from range of value in database
ResultSet Thru ResultSet