com.microsoft.sqlserver.jdbc.SQLServerException: 索引 1 超出范围。 at com.microsoft.sqlserver.jdbc.
在做模糊查询的时候报了索引超出范围的错误,大家帮我看看吧,俺新手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.setObject(Unknown Source)
at bbs.db.Database.executeQuery(Database.java:87)
at bbs.dao.Addtitledao.getAllTitleByTitlename(Addtitledao.java:77)
at bbs.servlet.TitlecontentAction.doTitle(TitlecontentAction.java:106)
at bbs.servlet.TitlecontentAction.doPost(TitlecontentAction.java:83)
at bbs.servlet.TitlecontentAction.doGet(TitlecontentAction.java:45)
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(Unknown Source)
public List<TitleInfo> getAllTitleByTitlename(String title)
{
List<TitleInfo> list = null;
String sql = "select * from Title where Tname like ' %" +title+"% '";
try
{
rs = data.executeQuery(sql, new Object[] { title });
if (rs != null)
{
list = new ArrayList<TitleInfo>();
while (rs.next())
{
TitleInfo temp = new TitleInfo();
//
temp.setAuthor(rs.getString("author"));
temp.setReplycount(rs.getInt("ReplyCount"));
temp.setClickcount(rs.getInt("Clickcount"));
temp.setTid(rs.getInt("T_id"));
temp.setTname(rs.getString("Tname"));
//
list.add(temp);
}
}
}
catch (SQLException e)
{
e.printStackTrace();
} finally {
data.closeResultSet();
data.closeStatement();
data.closeConnection();
}
return list;
} 展开
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.setObject(Unknown Source)
at bbs.db.Database.executeQuery(Database.java:87)
at bbs.dao.Addtitledao.getAllTitleByTitlename(Addtitledao.java:77)
at bbs.servlet.TitlecontentAction.doTitle(TitlecontentAction.java:106)
at bbs.servlet.TitlecontentAction.doPost(TitlecontentAction.java:83)
at bbs.servlet.TitlecontentAction.doGet(TitlecontentAction.java:45)
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(Unknown Source)
public List<TitleInfo> getAllTitleByTitlename(String title)
{
List<TitleInfo> list = null;
String sql = "select * from Title where Tname like ' %" +title+"% '";
try
{
rs = data.executeQuery(sql, new Object[] { title });
if (rs != null)
{
list = new ArrayList<TitleInfo>();
while (rs.next())
{
TitleInfo temp = new TitleInfo();
//
temp.setAuthor(rs.getString("author"));
temp.setReplycount(rs.getInt("ReplyCount"));
temp.setClickcount(rs.getInt("Clickcount"));
temp.setTid(rs.getInt("T_id"));
temp.setTname(rs.getString("Tname"));
//
list.add(temp);
}
}
}
catch (SQLException e)
{
e.printStackTrace();
} finally {
data.closeResultSet();
data.closeStatement();
data.closeConnection();
}
return list;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询