wood burning stoves*
The moose likes JDBC and the fly likes errjava.sql.SQLException: Parameter index out of range (9 > number of parameters, whi Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "errjava.sql.SQLException: Parameter index out of range (9 > number of parameters, whi" Watch "errjava.sql.SQLException: Parameter index out of range (9 > number of parameters, whi" New topic
Author

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

karthikbabu babu
Greenhorn

Joined: Aug 28, 2008
Posts: 1
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

Joined: Mar 02, 2005
Posts: 443
    
    1

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 ]
 
Consider Paul's rocket mass heater.
 
subject: errjava.sql.SQLException: Parameter index out of range (9 > number of parameters, whi