• 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 already closed error

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm trying to get the output parameter of a stored procedure as in the below code. However, after calling callableStatement.execute(), the callableStatement object gets closed, causing the call to getInt() to throw an SQLException saying, "java.sql.SQLException: Statement has already been closed". I'd like to know what I need to look at for me to get this to work.

I'm fairly confident that the SP call is correct; calling it from an SQL editor causes it to return values in the output parameters. Could this be something in my Weblogic settings (I'm using a non-XA datasource defined in Weblogic 10.3)? Does anyone know how I should go about testing this?

Here is part of the code that I have. Eclipse debug mode shows that the statement is still open before the execute() method is called, and closed at the getInt() method.



Thanks in advance!
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Christopher,
JDBC methods declare that they throw SQLException which is a checked exception and therefore your code must handle it.
So where is your error handling code?
What database are you using and what JDBC driver?
Perhaps your JDBC driver does not support "out" parameters?

Good Luck,
Avi.
 
Ranch Hand
Posts: 144
Oracle Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where in your code do you close your Connection and Statement? Is it possible that your connection is closed when the statement executes? It's not an exact scenario match, but I have seen people getting error from trying to access a ResultSet after the callling Statement was closed.
 
Christopher De Castro
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the replies. Apparently, it's a problem with my statement timeout property. The SP throws a runtime exception, and during the time while I'm checking my breakpoints, my statement times out and my debugger shows "The statement has already been closed" instead of the actual error.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic