1

I am trying to call a stored procedure from my java code and I am getting an sql exception. here is my code snippet

 CallableStatement cstmt = conn.prepareCall("{call stroredprocname(?,?,?)}");
                cstmt.setString(1, filePattern);
                cstmt.setString(2, fromDate);
                cstmt.setString(3, toDate);

                ResultSet resultSet = cstmt.executeQuery();

this is the error code i am getting:

com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -440, SQLSTATE: 42884, SQLERRMC: stroredprocname;PROCEDURE
    at com.ibm.db2.jcc.c.tf.e(tf.java:1680)
    at com.ibm.db2.jcc.c.tf.a(tf.java:1239)
    at com.ibm.db2.jcc.b.jb.h(jb.java:139)
    at com.ibm.db2.jcc.b.jb.d(jb.java:71)
    at com.ibm.db2.jcc.b.w.d(w.java:54)
    at com.ibm.db2.jcc.b.cc.i(cc.java:208)
    at com.ibm.db2.jcc.c.tf.o(tf.java:1236)
    at com.ibm.db2.jcc.c.uf.ib(uf.java:1831)
    at com.ibm.db2.jcc.c.uf.d(uf.java:2296)
    at com.ibm.db2.jcc.c.vf.Z(vf.java:159)
    at com.ibm.db2.jcc.c.vf.execute(vf.java:142)
    at MyClass(MyClass.java:102)

Could some please help me out! Thanks in advance!

8
  • Did you test(compile) your pl/sql in db itself? Commented Oct 24, 2014 at 18:50
  • The error above means it cannot find the store procedure.If it compile properly then I am sure that you have to provide schema name and proc name for example: call schemaname.stroredprocname(?,?,?) Commented Oct 24, 2014 at 18:56
  • Yes I compiled this in the DB itself. I tried giving the schema name as well it gave me an error like this now com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -313, SQLSTATE: 07001, SQLERRMC: null at com.ibm.db2.jcc.c.tf.d(tf.java:1396) at com.ibm.db2.jcc.b.jb.l(jb.java:367) at com.ibm.db2.jcc.b.jb.e(jb.java:92) at com.ibm.db2.jcc.b.w.e(w.java:72) at com.ibm.db2.jcc.b.cc.h(cc.java:203) at com.ibm.db2.jcc.c.tf.q(tf.java:1363) at com.ibm.db2.jcc.c.uf.d(uf.java:2388) at com.ibm.db2.jcc.c.vf.X(vf.java:188) at com.ibm.db2.jcc.c.vf.executeQuery(vf.java:171) Commented Oct 24, 2014 at 19:01
  • That's good, Please find the schema name and add to the code when calling store proc as I have mentioned in answer.It will work like charm. Commented Oct 24, 2014 at 19:04
  • What is your query look like? Can you please check the params? params mismatch most likely? Commented Oct 24, 2014 at 19:07

1 Answer 1

1

Error Definition 440 - Cannot find the store procedure location which means you have missed something which is schema name in your case.

Please add schema name right before the Procedure name for example:

CallableStatement cstmt = conn.prepareCall("{call schemaname.stroredprocname(?,?,?)}");

2nd Issue Error 313 - Parameters are not matching between your PL/SQL query and Java code.

Sign up to request clarification or add additional context in comments.

4 Comments

Hi Lokesh. Thank you much for answering my question so promptly! may i know if you have a reference of the error codes and what they mean? i resolved the error 313 by correcting the params now i am getting this com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -302, SQLSTATE: 22001, SQLERRMC: null
Well you can see at the very end it says null and Secondly, you can Google some of the error code as well,will give you some clue.Please upvote and mark the answer if it solved your issue. I am also a new developer who is constantly learning and sharing my knowledge over stack overflow.
This new error is causing because Data being inserted into the database table column is larger than the assigned column length. Reference link www-01.ibm.com/support/docview.wss?uid=swg21585238. In order to solve this go to database and increase the length of column.
I think you are trying to insert something into database?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.