标题:sql server 连接问题
取消只看楼主
wld1101
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2005-11-29
 问题点数:0 回复次数:0 
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)
搜索更多相关主题的帖子: sql server 
2005-11-29 14:30



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-35747-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.117046 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved