JSP用ODBC连接SQL2005问题
如题,我ODBC数据源弄好。用JSP连接,以前在学校机房都可以连接,这会儿在家里不行,
<%@ page contentType="text/html;charset=GB2312"%>
<%@ page import="java.sql.*" %>
<html>
<head><title>学生表</title>
</head>
<body>
<%
Connection con;
Statement sql;
ResultSet rs;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e) {}
try{
con=DriverManager.getConnection("jdbc:odbc:stu","sa","3166");
sql=con.createStatement();
rs=sql.executeQuery("Select * FROM student");
out.print("<br><br><br>");
out.print("<center>");
out.print("<h1><font color=blue>"+"学生表"+"</h1>");
out.print("</font>");
out.print("<table border=2>");
out.print("<tr>");
out.print("<th width=150>"+"学号");
out.print("<th width=150>"+"姓名");
out.print("<th width=150>"+"性别");
out.print("<th width=150>"+"年龄");
out.print("</tr>");
while(rs.next())
{
out.print("<tr>");
out.print("<td>"+rs.getString("id")+"</td>");
out.print("<td>"+rs.getString("name")+"</td>");
out.print("<td>"+rs.getString("sex")+"</td>");
out.print("<td>"+rs.getString("age")+"</td>");
out.print("</tr>");}
out.print("</table>");
out.print("</center>");
con.close();
}
catch(SQLException e){}
%>
<from><h2>test</h2></from>
</body>
</html>
我在最后加了个from表单,写了个test测试,浏览的时候,只有 test 出现。数据库内容并没有出现。是哪里出了问题呢?
JSP出现了一个窗口:An error has occurred.See error log for more details.
搜索更多相关主题的帖子:
ODBC JSP
----------------解决方案--------------------------------------------------------