Skip to Content
author's profile photo Former Member
Former Member

Oracle :Closed statement exception

Hi,

Iam trying to migrate a j2ee application to NetWeaver. Iam getting Oracele closed statement exception while executing a code which works fine with other servers like weblogic and jboss. My code is some thing like this

stmt = con.prepareStatement

result = stmt.executequery

if(result.next())

{

working_fine = result.getString("something");

callInsertMethod(con);

con.commit();

<b>not_working_fine = result.getString("somethingelse")</b>

}

I am getting this exception at the above bolded line. iam calling another method where some database insertions and al happen and connection commit also happens.Any help?

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Mar 24, 2006 at 01:12 PM

    Hi,

    The error should not occur if you are using the same database driver and jar set.

    Regards,

    S.Divakar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 25, 2006 at 09:13 PM

    Sujesh,

    if I understood correctly, you're calling bothe some instertions + commit in the method <b>callInsertMethod(con)</b> before the emphasised line is called. As far as my experience tells me, that's not ok, because a commit might clear/close other result sets on the same connection. For the code snippet you've posted I'd say just move the emphasized line before <b>callInsertMethod(con)</b>.

    Additionally I'd suggest to explicitly close the statement (the result set too if you're not relying on driver JDBC compliance) and if <b>callInsertMethod(con)</b> already commits, to delete the <b>con.commit()</b>.

    Btw., the JavaDoc should be your best friend, here a detail from java.sql.Connection.commit():

    Makes all changes made since the previous commit/rollback permanent and <b>releases any database locks</b> currently held by this Connection object. 

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.