一段不能现实的代码

red1981 2004-05-07 10:42:42
请教个问题:这段jsp代码,只显示HelloWorld,
但是try语句中的table这个静态页面(就是“用户名”“密码”)都没有显示,查询结果也没有现实。
真有点搞不懂,代码应该没问题了。

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<body>

<%
out.print("hello,World");

%>
<%
Connection con;
Statement sql;
ResultSet rs;

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc.odbc.DB_PKI");
sql=con.createStatement();
String condition="SELECT * FROM users";
rs=sql.executeQuery(condition);

out.print("<table border>");
out.print("<tr>");
out.print("<th width=80>"+"用户名");
out.print("<th width=100>"+"密码");
out.print("</tr>");

while(rs.next())
{
out.print("<tr>");
out.print("<td>"+rs.getString(1)+"</td>");
out.print("<td>"+rs.getString(2)+"</td>");

out.print("</tr>");
}
out.print("</table>");
con.close();
}
catch(Exception e){}

%>

</body>
</html>
...全文
60 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hyc4132 2004-05-07
  • 打赏
  • 举报
回复
在 out.print("<table border>"); 的前面就出现了异常,你可以在catch(Exception e){}中捕获异常看一下使那里的问题
kobetong 2004-05-07
  • 打赏
  • 举报
回复
调试的时候最好多看看报错信息,那样可以帮助你找出问题。

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧