sql server 连接问题
<%@ page contentType="text/html;charset=gb2312"%><%@ page import="java.sql.*"%>
<%
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=nullfada";
String user="sa";
String password="";
Connection con=DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement();
String sql="select * from person";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){
%>
第一个字段是<%=rs.getString(1)%>
di shi <%=rs.getString(2)%>
<%}%>
<%out.print("数据库连接成功");%>
<%rs.close();
stmt.close();
conn.close();
%>
错误信息:
type Exception report
message
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.JasperException: Unable to compile class for JSP An error occurred at line: 3 in the jsp file: /www.jsp Generated servlet error: conn cannot be resolved An error occurred at line: 18 in the jsp file: /www.jsp Generated servlet error: conn cannot be resolved org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:409) org.apache.jasper.compiler.Compiler.compile(Compiler.java:288) org.apache.jasper.compiler.Compiler.compile(Compiler.java:267) org.apache.jasper.compiler.Compiler.compile(Compiler.java:255) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)