Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4115554
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:35:49+00:00 2026-05-20T22:35:49+00:00

In the following code when if condition fails i.e when else block is reached

  • 0

In the following code when if condition fails i.e when else block is reached the procedure runs successfully else throws Closed Statement Exception:

 public synchronized void create(Map formMap) throws SQLException, Exception
  { 
    CallableStatement callStmt=null;    
    try
    {    
      String sql= "BEGIN UP_I_51(?, ?, ?, ?, ?, ?, ?, ?, ?); END;";   
      callStmt=getConnection().prepareCall(sql);
      callStmt.setString(1,formMap.get("periodFrom").toString());   
      callStmt.setString(2, formMap.get("periodTo").toString());
      String srcType=formMap.get("srcType").toString();
      callStmt.setString(3, srcType);
      callStmt.setString(4, formMap.get("collabIdMod").toString());
      callStmt.setString(5, formMap.get("name").toString());
      callStmt.setString(6, formMap.get("address").toString());
      callStmt.setString(7, " ");
      String parCollabId=formMap.get("pCollabId").toString();
      if(StringUtils.exists(parCollabId))
      {
        callStmt.setString(8, parCollabId);
        String parSrcType=getParentSrcType(srcType);
        callStmt.setString(9, parSrcType);
      }
      else
      {
        callStmt.setString(8, " ");
        callStmt.setString(9, " ");
      }   
      callStmt.executeUpdate(); 
    }
    finally
    {     
      callStmt.close();       
    }
  }

I replaced the code with below code and it is working now. I have used conditions when setting strings before but don’t know why exception comes now.

I still don’t understand why this exception comes. Could anyone find it?

 public synchronized void create(Map formMap) throws SQLException, Exception
  { 
        CallableStatement callStmt=null;    
        String srcType=formMap.get("srcType").toString();

        String parCollabId=formMap.get("pCollabId").toString();
        String parSrcType=getParentSrcType(srcType);
        try
        {    
            srcType=formMap.get("srcType").toString();
            parCollabId=formMap.get("pCollabId").toString();
            parSrcType=getParentSrcType(srcType);

            parCollabId = StringUtils.exists(parCollabId) ? parCollabId : " ";
            parSrcType = StringUtils.exists(parCollabId) ? parSrcType : " ";

            String sql= "{ call UP_I_51(?, ?, ?, ?, ?, ?, ?, ?, ?) }";  

          callStmt=getConnection().prepareCall(sql);
          callStmt.setString(1,formMap.get("periodFrom").toString());   
          callStmt.setString(2, formMap.get("periodTo").toString());

          callStmt.setString(3, srcType);
          callStmt.setString(4, formMap.get("collabIdMod").toString());
          callStmt.setString(5, formMap.get("name").toString());
          callStmt.setString(6, formMap.get("address").toString());
          callStmt.setString(7, " ");

          callStmt.setString(8, parCollabId);
          callStmt.setString(9, parSrcType);
          callStmt.executeUpdate(); 
        }catch(Exception e)
        {
            e.printStackTrace();
            throw e;
        }
        finally
        {     
          callStmt.close();       
        }
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:35:50+00:00Added an answer on May 20, 2026 at 10:35 pm

    There is so much missing it is hard to tell how you are using this, but, if you are closing the connection, so getConnection() returns something that isn’t open, that could be your problem.

    You should write a unit test, and call it two or three times in a row, from within the same test, to ensure that it is working properly.

    If it doesn’t you may want to have getConnection() ensure that the connection is open before returning the connection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've the following code.if i give control_word as 6 why if condition evaluates to
Using the following code: db_update('nodesequence_nodes') ->fields(array( 'order' => 1, )) ->condition('nid', 1, '=') ->condition('nsid',
I'm doing the following: [self.parentViewController dismissModalViewControllerAnimated:YES] This code fails using the Simulator but works
I have the following situation: if (condition) { std::unique_ptr<AClass> a(new AClass); // code that
I have the following code condition if len(content_tags) >= 1 or tags_irrelevant == 'yes'\
I'm following http://ruby.railstutorial.org/chapters/following-users#code:from_users_followed_by_final and these tests fails: describe status feed do it should have
the following code has a condition that has lt i was searching in the
I have the following code that simply loops looking for a condition and places
I have some code that does the following: while(some condition) { char *line[WORDLEN]; //do
I've been playing around with the following piece of code: class RunMeBaby { public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.