高手请帮忙

zwliu 2004-08-26 03:46:24
源代码如下:
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.sql.*"%>
<%@ page language="java"%>
<HTML>
<HEAD>
<TITLE>数据库管理实例</TITLE>
</HEAD>
<BODY>
<CENTER>
<FONT SIZE=2 COLOR=BLUE>
数据库管理
<CENTER>
<%
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=ctmsnew";
String user="sa";
String password="";
Connection con=java.sql.DriverManager.getConnection(url,user,password);
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs;
rs=stmt.executeQuery("select us_logid,us_name,us_password from suser");
%>

<TABLE bgcolor=DodgerBlue>
<TR bgcolor=SkyBlue>
<TD><FONT SIZE=2><B>用户编号</b></FONT></TD>
<TD><FONT SIZE=2><B>用户名</b></FONT></TD>
<TD><FONT SIZE=2><B>密码</b></FONT></TD></TR>
<%
while(rs.next()){
%>
<TR bgcolor=SkyBlue>
<TD><FONT SIZE=2><B><%=rs.getString(1)%></B></FONT></TD>
<TD><FONT SIZE=2><B><%=rs.getString(2)%></B></FONT></TD>
<TD><FONT SIZE=2><B><%=rs.getString(3)%></B></FONT></TD></TR>
<%
}
rs.close();
stmt.close();
con.close();
%>
</TABLE>
</CENTER>
</BODY>
</HTML>

出错提示:
Error: 500
Location: /myjsp/getdata.jsp
Internal Servlet Error:

org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
C:\jakarta-tomcat-3.2.3\work\localhost_8080\_0002fmyjsp_0002fgetdata_0002ejspgetdata_jsp_0.java:74: Ambiguous class: java.beans.Statement and java.sql.Statement
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
^
C:\jakarta-tomcat-3.2.3\work\localhost_8080\_0002fmyjsp_0002fgetdata_0002ejspgetdata_jsp_0.java:76: Variable stmt may not have been initialized.
rs=stmt.executeQuery("select us_logid,us_name,us_password from suser");
^
2 errors, 1 warning

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:612)
at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:542)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:258)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:268)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:536)

什么原因啊?
...全文
26 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
zwliu 2004-08-26
yys79,谢谢你的指教,我改成java.sql.Statement stmt=con.createStatement,还是出错如下:
javax.servlet.ServletException: Unable to load class com.microsoft.jdbc.sqlserver.SQLServerDriver
是我的驱动有问题吗?我可装了Microsoft SQL Server 2000 Driver for JDBC呀
回复
xiangbo520 2004-08-26
(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY)
应该是你的这个参数不对,可能打错了。
回复
loveunittesting 2004-08-26
这句:Statement stmt=con.createStatement
写成 java.sql.Statement stmt=con.createStatement
因为2个包内有名字相同的类。
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2004-08-26 03:46
社区公告
暂无公告