| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1005 人关注过本帖
标题:JSP连接数据库错误!请高手指教!
取消只看楼主 加入收藏
NameGf
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2005-3-9
收藏
 问题点数:0 回复次数:0 
JSP连接数据库错误!请高手指教!

JSP登陆验证代码: <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" import="java.util.*" import="java.io.*" import="java.lang.*" errorPage="" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>无标题文档</title> </head>

<body> <% //获得请求 String id=request.getParameter("username"); String psw=request.getParameter("password"); //连接数据库 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url="jdbc:odbc:TestData"; Connection con=DriverManager.getConnection(url); Statement stmt=con.createStatement(); String isCorrect="select * from user where username='" + id + "' and password='" + psw + "'"; ResultSet result=stmt.executeQuery(isCorrect); session.setAttribute("isLog",new String("0")); if(!result.next()) { response.sendRedirect("title.jsp"); result.close(); stmt.close(); con.close(); } //如果查询后有记录,说明登陆成功 else { //保存登陆信息到session对象中 session.setAttribute("userid",result.getString("userid")); session.setAttribute("id",result.getString("username")); session.setAttribute("email",result.getString("email")); session.setAttribute("isLog",new String("1")); stmt.close(); con.close(); response.sendRedirect("title.jsp"); } %> 输入数据库中的ID和password后TOMCAT给出的错误信息:

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: [Microsoft][ODBC Microsoft Access Driver] ??????????????
	org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
	org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
	org.apache.jsp.DATA.login_jsp._jspService(login_jsp.java:95)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

root cause

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] ??????????????
	sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6106)
	sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6263)
	sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:2525)
	sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:337)
	sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:252)
	org.apache.jsp.DATA.login_jsp._jspService(login_jsp.java:66)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

note The full stack trace of the root cause is available in the Tomcat logs. 请高手指教怎么修改!!!请请!

搜索更多相关主题的帖子: 数据库 JSP 指教 
2005-06-02 18:35
快速回复:JSP连接数据库错误!请高手指教!
数据加载中...
 
   



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

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