• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Statement is closed?

 
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry! I have an SQLConnection class that is creating the statement. Here it is:

Does that help?
Thanks again!
 
Blake Minghelli
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 just had the craziest dream. This tiny ad was in it.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic