JSP 连接SQLSERVER2000数据库怎么不成功啊?

来源:百度知道 编辑:UC知道 时间:2024/05/25 12:53:56
总是提示:
description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:520)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
测试程序为:
<%@ page import="java.lang.*, java.io.*, java.sql.*, java.util.*" contentType="text/html;charset=gb2312" %>
<html>
<body>
<% Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=test";

<%@ page contentType=\"text/html;charset=gb2312\"%>
<%@ page import=\"java.sql.*\"%>
<html>
<body>
<%
Class.forName(\"com.microsoft.jdbc.sqlserver.SQLServerDriver\").newInstance();
String url=\"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs\";
String user=\"sa\";
String password=\"sa\";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement();
String sql=\"select * from jobs\";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
<%=rs.getString(1)%>
<%}%>
<%rs.close();
stmt.close();
conn.close();
%>

</body>
<