<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<title>数据库连接</title>
</head>
<body>
<% Connection con;
java.sql.Statement sql;
ResultSet rs;
try{Class.forName("sun.jdbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){}
try {con=DriverManager.getConnection("jdbc:odbc:sun","sa","");
sql=con.createStatement();
rs=sql.executeQuery("select * from student");
out.print("<Table border>");
out.print("<TR>");
out.print("<TH width=100>"+"学号");
out.print("<TH width=100>"+"姓名");
out.print("<TH width=100>"+"数学成绩");
out.print("<TH width=100>"+"英语成绩");
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("<TD>"+rs.getInt("数学成绩")+"</TD>");
out.print("<TD>"+rs.getInt("英语成绩")+"</TD>");
out.print("<TD>"+rs.getInt("物理成绩")+"</TD>");
out.print("</TR>");
}
out.print("</table>");
con.close();
}
catch(SQLException e1){}
%>
</body>
</html>
调试什么都没有,也没有错误,高手们帮我改下,使得它能够把表的内容显示出来.