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;
}
展开
 我来答
非常人选0_0
2010-12-06
知道答主
回答量:2
采纳率:0%
帮助的人:0
展开全部
哥们,你和我刚才的错误一样啊,是SQL语句错了,看是否你也是这个错误啊单引号和双引号那里错了
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式