java.sql.SQLException: Invalid parameter index 1.
请问这是什么错误啊。
我的代码是这样的,
String Inputxm=PageParameter.GetParameter(request,"Txt_xm","");//管理员姓名
String Inputid=PageParameter.GetParameter(request,"Txt_id","");//管理员编号
System.out.println("inputxm="+Inputxm);
String WhereSqltxt="";
ArrayList<String> WhereParameter=new ArrayList<String>();
if(Inputxm.length()>5 || Inputid.length()>3){
throw new Exception("错误的参数类型");
}
if(!Inputxm.equals("")){
WhereSqltxt+="and name like '% ? % '"; //管理员姓名sql
WhereParameter.add(Inputxm);
}
if(!Inputid.equals("")){
WhereSqltxt+="and id=? "; //管理员编号sql
WhereParameter.add(Inputid);
}
Connection conn=new DBBase().GetReadConn();
PreparedStatement ppstmt=null;
ResultSet rs=null;
try{
String SelectSql="select 管理员=name,管理员编号=id,性别=sex,身份证号=sfzbh, 所在公司编号=gsbh,拥有权限=qx,密码=password,备注=bz from gjic..user_p";
if(!WhereSqltxt.equals("")) {
SelectSql+=" where "+WhereSqltxt.substring(4);
}
System.out.println("SelectSql="+SelectSql);
打印出来的SQL语句是
SelectSql=select 管理员=name,管理员编号=id,性别=sex,身份证号=sfzbh, 所在公司编号=gsbh,拥有权限=qx,密码=password,备注=bz from gjic..user_p where name like '% ? % '
java.sql.SQLException: Invalid parameter index 1.