java.sql.SQLException: Parameter index out of range (0 < 1 ).

I got this message " java.sql.SQLException: Parameter index out of range (0 < 1 ) " when i try to pass data from a servlet to mysql database using a stored procedure and callable statement. i have to pass 13 parameters stored in array.

Please help me

Here is the code

Connection con=null;

CallableStatement proc =null;

try

{

Class.forName("com.mysql.jdbc.Driver").newInstance();

con = DriverManager.getConnection("jdbc:mysql:///projectclaire","root","");

proc = con.prepareCall("{ call do_upcli(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) }");

for (int k=0;k <elts.length;k++)

{

proc.setString(k, elts[k]);

}

proc.setInt(13, b2);

proc.setInt(14, b3);

proc.execute();

response.sendRedirect("http://localhost:8080/uct/success3.jsp");;

proc.close();

}

catch(Exception e)

{

System.err.println("Exception: " + e.getMessage());

out.println(e);

out.println(e.getMessage());

}

>

[1585 byte] By [uxiana] at [2007-11-26 21:01:24]
# 1
Change:proc.setString(k, elts[k]);toproc.setString(k + 1, elts[k]); And I hope that "elts" only has 12 elements (or at least not more than 14).
masijade.a at 2007-7-10 2:32:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
parameters numberings start from 1 and not from 0, unlike java/c.see the API, you will find this note. start setting the parameters from 1.Your code will work fine.Hope this helps.
ayusman_dikshita at 2007-7-10 2:32:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
Thanks a lot masijade , i did in the way you showed me and it is running very well i have just write k+1 , thanks a lot.
uxiana at 2007-7-10 2:32:54 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...