Announcement Announcement Module
Collapse
No announcement yet.
Stored Procedure throwing error: Method can be called only once Informix Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stored Procedure throwing error: Method can be called only once Informix

    On running a stored procedure after extending the spring storedprocedure class I am getting the error shown below. The same procedure works fine if I call preparedstatement and hardcode the function.

    This is the code that I am using.
    *******NOT WORKING ***********************

    public class ProcessTransStoredProc extends StoredProcedure {

    private static final Logger logger = Logger.getLogger(ProcessTransStoredProc.class);

    private static final String STORED_PROC_NAME = "DSPCHG9900";
    private static final String CASE_ID = "p_case_id";
    public ProcessTransStoredProc(DataSource ds) {
    super(ds, STORED_PROC_NAME);
    //compile();
    }

    Map<String, Integer> inParams = new HashMap<String, Integer>(1);

    public void execute(int idCase){
    declareParameter(new SqlParameter(CASE_ID, Types.INTEGER));
    inParams.put(CASE_ID, idCase);
    execute(inParams);
    }

    }

    ***** PREVIOUSLY WORKING *********************

    private boolean runProc(int id, String procName) {

    Session session = sessionFactory.getCurrentSession();
    try {
    PreparedStatement st = session.connection().prepareStatement("{call " + procName + " (?);}");
    st.setString(1, new Integer(id).toString());
    //st.setString(2, "DSPCHG");
    return st.execute();
    } catch(SQLException sqle) {
    throw new DCSSRuntimeException(sqle.getMessage(), sqle.getCause());
    }
    }


    public boolean dispchg9900(int id){
    return runProc(id, "DSPCHG9900");
    }

    Stack trace:

    dars.dcss.service.exceptions.DCSSRuntimeException: CallableStatementCallback; uncategorized SQLException for SQL [{call DSPCHG9900(?)}]; SQL state [IX000]; error code [-79782]; Method can be called only once.; nested exception is java.sql.SQLException: Method can be called only once.
    at com.informix.util.IfxErrMsg.getSQLException(IfxErr Msg.java:355)
    at com.informix.jdbc.IfxStatement.getUpdateCount(IfxS tatement.java:684)
    at org.apache.commons.dbcp.DelegatingStatement.getUpd ateCount(DelegatingStatement.java:264)
    at org.springframework.jdbc.core.JdbcTemplate.extract ReturnedResultSets(JdbcTemplate.java:958)
    at org.springframework.jdbc.core.JdbcTemplate$5.doInC allableStatement(JdbcTemplate.java:920)
    at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:878)
    at org.springframework.jdbc.core.JdbcTemplate.call(Jd bcTemplate.java:910)
    at org.springframework.jdbc.object.StoredProcedure.ex ecute(StoredProcedure.java:113)
    at dars.dcss.domain.common.ProcessTransStoredProc.exe cute(ProcessTransStoredProc.java:31)
    at dars.dcss.domain.common.ProcessTransDaoImpl.dispch g9900(ProcessTransDaoImpl.java:32)
    at dars.dcss.business.test.processtrans.ProcessTransT est.dspchg9900(ProcessTransTest.java:16)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.internal.runners.TestMethodRunner.execut eMethodBody(TestMethodRunner.java:99)
    at org.junit.internal.runners.TestMethodRunner.runUnp rotected(TestMethodRunner.java:81)
    at org.junit.internal.runners.BeforeAndAfterRunner.ru nProtected(BeforeAndAfterRunner.java:34)
    at org.junit.internal.runners.TestMethodRunner.runMet hod(TestMethodRunner.java:75)
    at org.junit.internal.runners.TestMethodRunner.run(Te stMethodRunner.java:45)
    at org.junit.internal.runners.TestClassMethodsRunner. invokeTestMethod(TestClassMethodsRunner.java:71)
    at org.junit.internal.runners.TestClassMethodsRunner. run(TestClassMethodsRunner.java:35)
    at org.junit.internal.runners.TestClassRunner$1.runUn protected(TestClassRunner.java:42)
    at org.junit.internal.runners.BeforeAndAfterRunner.ru nProtected(BeforeAndAfterRunner.java:34)
    at org.junit.internal.runners.TestClassRunner.run(Tes tClassRunner.java:52)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.run(JUnit4TestReference.java:38)
    at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:196)
    Caused by: java.sql.SQLException: Method can be called only once.
    ... 31 more

  • #2
    informix bug

    Hi,

    the error below was due to a spring-informix issue. I tried the same thing with mySql d/b and it worked perfectly fine.

    Rahul

    Comment

    Working...
    X