com.microsoft.sqlserver.jdbc.SQLServerException: 索引 1 超出范围 错误:
com.microsoft.sqlserver.jdbc.SQLServerException: 索引 1 超出范围。
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setterGetParam(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setString(Unknown Source)
at Model.GoodsBeanBo.getGoodsBeans(GoodsBeanBo.java:19)
at Servlet.ShowGoods.doGet(ShowGoods.java:40)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
代码:private Connection ct = null;
private PreparedStatement ps = null;
private ResultSet rs = null;
GoodsBeans gb = new GoodsBeans();
public GoodsBeans getGoodsBeans(String goodsId) {
// 根据ID,取得信息
GoodsBeans gb = new GoodsBeans();
try {
ct = new ConnDB().getConnection();
ps = ct.prepareStatement("select * from goods where goodsId=''");
ps.setString(1, goodsId);
rs = ps.executeQuery();
if (rs.next()) {
gb.setGoodsId(rs.getInt(1));
gb.setGoodsName(rs.getString(2));
gb.setGoodsIntro(rs.getString(3));
gb.setGoodsPrice(rs.getFloat(4));
gb.setGoodsNum(rs.getInt(5));
gb.setGoodsProd(rs.getString(6));
gb.setGoodsPhoto(rs.getString(7));
gb.setGoodsType(rs.getString(8));