读数据库的问题??? 请教!!!

styq2000 2004-10-04 06:25:46
我在做一个论坛,用JSP实现,在读取帖子的时候出现如下错误!
请教问题所在?? 谢谢!!
HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: [Microsoft][ODBC SQL Server Driver]无效的描述符索引
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
org.apache.jsp.tiny.forum.article_jsp._jspService(article_jsp.java:284)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


root cause

java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]无效的描述符索引
sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:3908)
sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultSet.java:5702)
sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:356)
sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:413)
org.apache.jsp.tiny.forum.article_jsp._jspService(article_jsp.java:195)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


note The full stack trace of the root cause is available in the Tomcat logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.18
...全文
109 点赞 收藏 7
写回复
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Drate 2004-10-07
http://search.csdn.net/Expert/topic/1619/1619032.xml?temp=.5700647
http://search.csdn.net/Expert/topic/858/858207.xml?temp=.0789606

http://search.csdn.net/Expert/topic/1041/1041290.xml?temp=.948208

哈哈,我把你的问题搜索出一个直接的答案来了
====
这句话也是贴的人家的。
已在另外那个帖子里给出了答案。呵呵,你应该多用用CSDN的“搜索”,我就是用“无效的描述符索引”来搜索论坛,才知道答案的。
回复
SnailLi 2004-10-07
换成第四类jdbc驱动吧?jdbc-odbc桥很落后的!!!!
回复
ohappy 2004-10-07
把test.conn的源码贴出来,可能是数据库连接错误!!
回复
zzyy1998 2004-10-07
你在哪里连接数据库啊,我好象没有看到
回复
styq2000 2004-10-06
我自己顶一下:)
回复
styq2000 2004-10-04
<%@ include file="../member/header.inc"%>
<%@ page language="java" import="java.sql.*" %>
<jsp:useBean id="workM" scope="page" class="test.conn" />

<%!
public String getStr(String str)
{
try
{
String temp_p=str;
byte[] temp_t=temp_p.getBytes("GBK");
String temp=new String(temp_t,"ISO8859_1");
return temp;
}
catch(Exception e)
{

}
return "null";
}
%>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=760 align="center">
<TBODY>
<tr><td align="left" height=25>当前位置:<a href="../index.jsp">首页</a> -> <a href="index.jsp">论坛</a> </td>

</tr>
<TR bgColor=#3399ff>
<TD height=1 colspan="2"><IMG height=1 src="images/spacer.gif"
width=16></TD></TR>
<tr><td height=10 colspan="2"><IMG height=1 src="images/spacer.gif"
width=16></td></tr>
</TBODY></TABLE>

<table align="center" border="0" width="760" cellspacing="0" cellpadding="0" height="355">
<tr>
<td width="150" height="355" valign="top">
<%@ include file="../member/table.inc"%>

</td>
<td width="10" height="100%"></td>
<td width="1" height="100%" bgcolor="#3399ff"></td>
<td width="10" height="100%"></td>
<td width="589" height="331" valign="top" background="images/bg1.gif">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3" width="100%" height="20" bgcolor="#3399ff"> <font color="#ffffff">论坛 -> 详细查看</font>
</td>
</tr>
<tr>

<td align="center" colspan='3' valign="top">


<%
String id;
id=request.getParameter("id");
String strSQL="select * from topic where id ="+id;
ResultSet RSa = workM.executeQuery(strSQL);
//out.println(strSQL);

while (RSa.next()) {
String a_author;
int topic_id;
topic_id=RSa.getInt("id");
a_author=getStr(RSa.getString("author"));
out.println("<br><b><font color=red>"+getStr(RSa.getString("title"))+"</font></b><br>"+a_author+" "+RSa.getDate("date")+"<br><br></td></tr><tr><td colspan='3' align='right'>");
if(a_author.equals(session.getValue("username")))
{
out.println("<a href=edit.jsp?mode=topic&id="+topic_id+">编 辑</a>  <a href=delete.jsp?mode=topic&id="+topic_id+">删 除</a>   ");
}
out.println("<a href=reply.jsp?id="+id+">回 复</a>   <a href=index.jsp>返 回</a></td></tr><tr><td colspan='3' height='1' bgcolor='#3399ff'></td></tr><tr><td width='5%'></td>");
out.println("<td><br>作者:"+a_author+"<br><br>");
out.println(getStr(RSa.getString("content")));

}
RSa.close();

%>


</td>
<td width="5%"></td>
</tr>

<%
// String id;
// id=request.getParameter("id");
String strRe="SELECT * FROM reply where topicID="+id;
ResultSet RSr = workM.executeQuery(strRe);
//out.println(strSQL);

while (RSr.next()) {
%>

<%
String a_author,t_id;
t_id=RSr.getString("id");
a_author=getStr(RSr.getString("author"));
out.println("<tr><td colspan='3' height='1' bgcolor='#3399ff'></td></tr>");
out.println("<tr><td colspan='3' align='right'>");
if(a_author.equals(session.getValue("username")))
{
out.print("<a href=edit.jsp?mode=reply&id="+t_id+">编 辑</a>  <a href=delete.jsp?mode=reply&id="+t_id+">删 除</a>   ");
}
out.print("<a href=reply.jsp?id="+id+">回 复</a>   <a href=index.jsp>返 回</a></td></tr>");
out.println("<tr><td align=center colspan='3' valign=top>");
out.print("<br><b>"+getStr(RSr.getString("title"))+"</b><br>"+a_author+" "+RSr.getDate("date")+"<br><br></td></tr>");
out.print("<tr><td width='5%'></td>");
out.print("<td><br>作者:"+a_author+"<br><br>");
out.print(getStr(RSr.getString("content")));
%>
</td>
<td width="5%"></td>
</tr>
<%
}
RSr.close();

%>

</table>
</td>
</tr>
</table>
<%@ include file="../member/footer.inc"%>


这就是源代码请帮忙看看!
谢谢了
回复
dext 2004-10-04
把代码贴出来!
估计是SQL错误!
回复
发动态
发帖子
Web 开发
创建于2007-09-28

7.9w+

社区成员

Java Web 开发
申请成为版主
社区公告
暂无公告