jsp链接sql server 2005错误
jsp源代码为
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'test_sql.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*"%>
<%!
Connection con;
Statement sql;
ResultSet rs;
%>
<%
Class.forName("com.microsoft.sqlserver.jdbc");
String url="jdbc:sqlserver://localhost:1433;DatabaseName=mis";
con=DriverManager.getConnection(url,"sa","sa");
sql=con.createStatement();
String sqlexe="select * from identity_check";
rs=sql.executeQuery(sqlexe);
rs.next();
out.println(rs.getString(1));
out.println("数据库连接成功!");
%>
</body>
</html>
错误提示为:
HTTP Status 500 - An exception occurred processing JSP page /test_sql.jsp at line 35
type Exception report
message An exception occurred processing JSP page /test_sql.jsp at line 35
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /test_sql.jsp at line 35
32: %>
33: <%
34:
35: Class.forName("com.microsoft.sqlserver.jdbc");
36: String url="jdbc:sqlserver://localhost:1433;DatabaseName=mis";
37: con=DriverManager.getConnection(url,"sa","sa");
38: sql=con.createStatement();
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handle
JspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspSe