Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Database/JDBC/SQL/JDO/Hibernate » Other DB  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 JDBC连接ACCESS数据库出错?(cannot find symbol)
komalee





发贴: 3
积分: 0
于 2006-05-29 10:41 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我用Tomcat 5.028服务器,ACCESS 2003数据库,做JSP登陆验证出现以下错误,不知道怎么搞的请高手多点指点!!
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page language="java" import="java.sql.*"%>
<%
String name=request.getParameter("Username");
String pass=request.getParameter("passWd");

boolean bl;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
String url="jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=F:\\koma\\Tomcat 5.0\\webapps\\netdiskWA\\users.mdb";
Connection conn = DriverManager.getConnection(url,"","");
Statement stmt=conn.createStatement();
PreparedStatement stmt=conn.prepareStatement(
"select * from users where username=name and password=pass");

ResultSet result=stmt.executeQuery();
result.setString(username);
result.setString(password);

if(result.next())
bl=true;
else
bl=false;

}
catch(Exception e)
{
out.println(e);
}
if(bl)
response.sendRedirect("FileManage.jsp");
else
response.sendRedirect("error.jsp");


why edited on 2006-05-29 22:24

风----
催生涅磐之火
经典的色彩从脉络中慢慢渗出
斑斓的翅膀带走蝶的绮舞
驱走曾经的季节
我看见一只凤泣在树颠
作者 Re:JDBC连接ACCESS数据库出错??? [Re:komalee]
komalee





发贴: 3
积分: 0
于 2006-05-29 10:42 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
错误如下:
HTTP Status 500 -

--------------------------------------------------------------------------------

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

An error occurred at line: 3 in the jsp file: /login.jsp
Generated servlet error:
F:\koma\Tomcat 5.0\work\Catalina\localhost\netdiskWA\org\apache\jsp\login_jsp.java:57: stmt is already defined in _jspService(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
PreparedStatement stmt=conn.prepareStatement(
^

An error occurred at line: 3 in the jsp file: /login.jsp
Generated servlet error:
F:\koma\Tomcat 5.0\work\Catalina\localhost\netdiskWA\org\apache\jsp\login_jsp.java:61: executeQuery(java.lang.String) in java.sql.Statement cannot be applied to ()
ResultSet result=stmt.executeQuery();
^

An error occurred at line: 3 in the jsp file: /login.jsp
Generated servlet error:
F:\koma\Tomcat 5.0\work\Catalina\localhost\netdiskWA\org\apache\jsp\login_jsp.java:62: cannot find symbol
symbol : variable username
location: class org.apache.jsp.login_jsp
result.setString(username);
^

An error occurred at line: 3 in the jsp file: /login.jsp
Generated servlet error:
F:\koma\Tomcat 5.0\work\Catalina\localhost\netdiskWA\org\apache\jsp\login_jsp.java:64: cannot find symbol
symbol : variable password
location: class org.apache.jsp.login_jsp
result.setString(password);
^
4 errors

org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
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)

note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.

--------------------------------------------------------------------------------

Apache Tomcat/5.0.28



风----
催生涅磐之火
经典的色彩从脉络中慢慢渗出
斑斓的翅膀带走蝶的绮舞
驱走曾经的季节
我看见一只凤泣在树颠
作者 Re:JDBC连接ACCESS数据库出错?(cannot find symbol) [Re:komalee]
why

問題兒童

总版主


发贴: 4629
积分: 388
于 2006-05-29 22:29 user profilesend a private message to usersend email to whysearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Sigh...

> stmt is already defined in
Statement stmt=conn.createStatement();
PreparedStatement stmt=conn.prepareStatement(

> PreparedStatement stmt=conn.prepareStatement("select * from users where username=name and password=pass");
where username=? and password=?

> cannot find symbol symbol : variable username
String name=request.getParameter("Username");
String pass=request.getParameter("passWd");
...
result.setString(username);
result.setString(password);




flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923