主题:找高手求助!jsp连sqlserver问题
sqlserver
[专家分:0] 发布于 2005-08-15 14:27:00
为什么我的jsp运行后屏幕显示是白屏啊?
这样是不是没有连上数据库阿?有没有高手能教教小弟怎么做啊?!![em10]
回复列表 (共2个回复)
沙发
zjjsgxx [专家分:470] 发布于 2005-08-16 09:14:00
看代码.
板凳
sqlserver [专家分:0] 发布于 2005-08-20 14:20:00
这是我的代码:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>学籍管理系统</title>
</head>
<body>
<% Connection con;
Statement sql;
ResultSet rs;
try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){out.print("java.error");}
try { con=DriverManager.getConnection("jdbc:odbc:sun","lujia","1");
sql=con.createStatement();
rs=sql.executeQuery("SELECT * FROM students");
out.print("<table width=600 border>");
out.print("<TR>");
out.print("<TH width=100 align=center>"+"学号");
out.print("<TH width=100 align=center>"+"姓名");
out.print("<TH width=50 align=center>"+"性别");
out.print("<TH width=50 align=center>"+"年龄");
out.print("<TH width=100 align=center>"+"籍贯");
out.print("<TH width=100 align=center>"+"院系");
out.print("</TR>");
while(rs.next())
{out.print("<tr>");
out.print("<td width=100 align=center>"+rs.getString(1)+"</td>");
out.print("<td width=100 align=center>"+rs.getString(2)+"</td>");
out.print("<td width=50 align=center>"+rs.getString(3)+"</td>");
out.print("<td width=50 align=center>"+rs.getString(4)+"</td>");
out.print("<td width=100 align=center>"+rs.getString(5)+"</td>");
out.print("<td width=100 align=center>"+rs.getString(6)+"</td>");
out.print("</tr>");
}
out.print("</table>");
con.close();
}
catch(SQLException e1) {out.print("sql error!");}
%>
</body>
</html>
错误提示:aql error!
我来回复