Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

errjava.sql.SQLException: Parameter index out of range (9 > number of parameters, whi

 
karthikbabu babu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello frds.....

tis is my code

try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con= DriverManager.getConnection("jdbc:mysql://localhost:3306/karthik","root","root");
out.println("conn");

CallableStatement cst = con.prepareCall("{call spname(?,?,?,?,?,?)}");

out.println("conn1");
ResultSet rs1=cst.executeQuery("select CURRENT_DATE from dual");
while(rs1.next())
{
curr_dt=rs1.getString(1);
}

out.println("conn2");

cst.setString(1,"q");
cst.setInt(2,41);
cst.setString(3,"'ss");
cst.setFloat(4, 54);

cst.setString(9, "name1");
cst.setInt(10,21);

ResultSet rs= cst.executeQuery();
cst.close();
out.println("updated");


wen i insert into table by using Stored procedure upto conn2 its working that is its printing.... after tat i cud nt insert the values....
the err is errjava.sql.SQLException: Parameter index out of range (9 > number of parameters, whi
 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

In your CallableStatement cst you have only 6 parameters declared and with -

cst.setString(9, "name1");
cst.setInt(10,21);


you are trying to set the 9th and 10th parameters which dont exist?

Cheers,
Raj.
[ September 19, 2008: Message edited by: Raj Kamal ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic