Announcement Announcement Module
Collapse
No announcement yet.
error code [17041]; Missing IN or OUT parameter at index:: Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • error code [17041]; Missing IN or OUT parameter at index::

    Hi,

    I am getting an SQLException while invoking a stored procedure from Java. I am not able to figure out what is wrong with the code. Below is the exception and the code snippet. Urgent help required. Please:-(

    Exception :

    Exception in thread "main" org.springframework.jdbc.UncategorizedSQLException : CallableStatementCallback; uncategorized SQLException for SQL [{? = call {call MYPKG.MYPROC(?,?,?)}(?, ?)}]; SQL state [99999]; error code [17041]; Missing IN or OUT parameter at index:: 4; nested exception is java.sql.SQLException: Missing IN or OUT parameter at index:: 4
    at org.springframework.jdbc.support.SQLStateSQLExcept ionTranslator.translate(SQLStateSQLExceptionTransl ator.java:124)
    at org.springframework.jdbc.support.SQLErrorCodeSQLEx ceptionTranslator.translate(SQLErrorCodeSQLExcepti onTranslator.java:322)
    at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:951)
    at org.springframework.jdbc.core.JdbcTemplate.call(Jd bcTemplate.java:984)
    at org.springframework.jdbc.object.StoredProcedure.ex ecute(StoredProcedure.java:117)
    at StoredProcTest.execute(StoredProcTest.java:39)
    at StoredProcTest.main(StoredProcTest.java:51)
    Caused by: java.sql.SQLException: Missing IN or OUT parameter at index:: 4


    I have just written a simple test class to invoke the stored procedure.

    import java.sql.Types;
    import java.util.HashMap;
    import java.util.Map;

    import javax.sql.DataSource;

    import org.springframework.context.support.ClassPathXmlAp plicationContext;
    import org.springframework.jdbc.object.StoredProcedure;
    import org.springframework.jdbc.core.SqlParameter;

    public class StoredProcTest extends StoredProcedure {

    /**
    * @param args
    */

    private DataSource dataSource;

    public StoredProcTest(DataSource ds) {
    super( ds, "{call MYPKG.MYPROC(?,?,?)}" );

    declareParameter( new SqlParameter( "P_CUST_ID", Types.VARCHAR) );
    declareParameter( new SqlParameter( "P_CREATE_USER_ID", Types.VARCHAR) );
    declareParameter( new SqlParameter( "P_MDN", Types.VARCHAR) );
    setFunction(true);
    compile();
    }
    public void execute(String cust_ref, String create_user, String MDN){
    Map<String, Object> inParams = new HashMap<String, Object>();
    inParams.put("P_CUST_ID", cust_ref);
    inParams.put("P_CREATE_USER_ID", create_user);
    inParams.put("P_MDN", MDN);
    super.execute(inParams);

    }
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    System.out.println("Before getting the context");
    org.springframework.context.ApplicationContext context =
    new ClassPathXmlApplicationContext("Beans.xml");

    System.out.println("context is " + context);
    System.out.println("After getting the context");
    StoredProcTest test = new StoredProcTest((DataSource) context.getBean("dataSource"));
    test.execute("25322533558762954", "USER1", "7606160553");

    }

    }


    Here is the declaration of the procedure.

    CREATE OR REPLACE PACKAGE MYPKG is

    PROCEDURE MYPROC (
    p_CUST_ID IN VARCHAR2,
    p_CREATE_USER_ID IN VARCHAR2,
    P_MDN IN VARCHAR2);
    end MYPKG;
Working...
X