求助Java,程序里报错。

java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
at com.mysql.jdbc.PreparedStatement.checkBounds(PreparedStatement.java:3717)
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3701)
at com.mysql.jdbc.PreparedStatement.setString(PreparedStatement.java:4552)
at com.qst.dao.InfoDao.searchInfoById(InfoDao.java:69)
at com.qst.servlet.InfoServlet.doGet(InfoServlet.java:61)
at com.qst.servlet.InfoServlet.doPost(InfoServlet.java:117)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at veh_info.EncodingFilter.doFilter(EncodingFilter.java:46)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2503)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2492)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)

我的InfoDao:69行:  ps.setString(1, infoid);
/**
 * 根据id查询信息
 * @param infoid
 * @return
 */
public List<Info> searchInfoById(String infoid ,int begin,int end) {
    List<Info> infolist = new ArrayList<Info>();
    try {
        con = JDBCUtil.getConnections(con);
        String sql = "select * from veh_info ";
        if(infoid != null && !"".equals(infoid)){
              sql += " where id = ? ";
          }
        sql +=" order by id LIMIT "+begin+","+end+"";
        ps = con.prepareStatement(sql);
        ps.setString(1, infoid);
        rs = ps.executeQuery();
        while(rs.next()){
            Info info =new Info();
            info.setId(rs.getString("id"));
            info.setDriver(rs.getString("driver"));
            info.setType(rs.getString("type"));
            info.setPlateNo(rs.getString("plateNo"));
            info.setLoad(rs.getFloat("load"));
            info.setPhone(rs.getString("phone"));
            infolist.add(info);
        }       
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }finally {
        JDBCUtil.close(rs, stat, ps, con);
    }

    return infolist;
}

InfoServlet:
61行:List<Info> infolist = dao.searchInfoById(idStr,(gopage-1)*6,rows);
117行:doGet(request, response);

    at veh_info.EncodingFilter.doFilter(EncodingFilter.java:46):
            chain.doFilter(request, response);

1个回答

infoid 是空吧,呵呵

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐