Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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.
 
Once upon a time there were three bears. And they were visted by a golden haired tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic