jsp数据库连接错误,我初学没有经验请指教.

来源:百度知道 编辑:UC知道 时间:2024/09/21 23:31:53
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: Exception in JSP: /admin/login.jsp:21

18:
19: LoginBean.openConnection();
20: String sql = "select * from "+user_table+" where user_account=\""+ user_account +"\" and user_password=\""+ user_password +"\"";
21: ResultSet rs = LoginBean.executeQuery(sql);
22: if (rs.next()) {
23: out.println("in record");
24: session.putValue("user_id",rs.getString("user_id"));

Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apach

net.jspcn.db.DbConnect.executeQuery(DbConnect.java:113)
我觉得是你的SQL语句写错了,加点空格试试,比如“select * from ”from后边有空格,别的也是,你加上试试吧。
String sql = "select * from "+user_table+" where user_account="+ user_account +" and user_password="+ user_password;
如果user_table是表名,不是变量,那写成
String sql = "select * from user_table where user_account= "+ user_account +" and user_password= "+ user_password;