求大神帮忙!
报错信息如下:
<%@ page language="java" import="java.sql.*" contentType="text/html; charset=gbk" pageEncoding="gbk"%>
<jsp:useBean id="dbcon" class="bean.DBcon" scope="request"/>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>查验</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%String name=request.getParameter("name");
String pwd=request.getParameter("password");
Connection dbCon=dbcon.getConnection();
Statement stmt=dbCon.createStatement();
ResultSet rs=stmt.executeQuery("select * from userinfo where loginname="+name+" and password="+pwd);
rs.last();
if(rs.next()){
session.setAttribute("name", "用户名");
session.setAttribute("pwd","密码");
response.sendRedirect("main.jsp");
}else{
response.sendRedirect("index.html");
}
rs.close();
stmt.close();
dbCon.close();
%>
</body>
</html>
报错语句为Statement stmt=dbCon.createStatement();
但是真的不知道哪里错了呀
JavaBean——DBcon.java代码
package bean;
import java.sql.*;
public class DBcon {
private static final String DRIVER_CLASS="com.mysql.jdbc.Driver";
private static final String DATABASE_URL="jdbc:mysql://localhost:3306/books?useUnicode=true&characterEncoding=UTF-8";
private static final String DATABASE_USER="root";
private static final String DATABASE_PASSWORD="admin";
public static Connection getConnection(){
Connection dbConnection=null;
try{
Class.forName(DRIVER_CLASS);
dbConnection=DriverManager.getConnection(DATABASE_URL, DATABASE_USER, DATABASE_PASSWORD);
}catch(Exception e){
e.printStackTrace();
}
return dbConnection;
}
public static void closeConnection(Connection dbConnection){
try{
if(dbConnection!=null&&(!dbConnection.isClosed())){
dbConnection.close();
}
}catch(SQLException sqlEx){
sqlEx.printStackTrace();
}
}
public static void closeResultSet(ResultSet res){
try{
if(res!=null){
res.close();
res=null;
}
}catch(SQLException e){
e.printStackTrace();
}
}
public static void closeStatement(PreparedStatement pStatement){
try{
if(pStatement!=null){
pStatement.close();
pStatement=null;
}
}catch(SQLException e){
e.printStackTrace();
}
}
}
求大神帮忙!