日期:2014-05-17  浏览次数:21065 次

Jsp+JavaBean+MySql实现登陆及增删改查出错。
Jsp+JavaBean+MySql实现登陆及增删改查出错。
运行环境:Tomcat6.0+jdk1.6+MyEclipse6.0 

报错信息:

type Exception report

message 

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

exception 

org.apache.jasper.JasperException: /ADMS/WebRoot/add.jsp(2,0) The value for the useBean class attribute bean.SqlConn is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1200)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1155)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2386)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2392)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
org.apache.jasper.compiler.Generator.generate(Generator.java:3394)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:210)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


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

我的代码
1.SqlConn.java

package bean;
import java.sql.*;

public class SqlConn {
private String url = "jdbc:mysql://localhost:3036/adms";
private String user = "root";
private String password = "root";

private Connection conn = null;
private Statement stmt = null;
private ResultSet rs = null;

public SqlConn(){
try{
Class.forName("com.mysql.jdbc.Driver");
}
catch(java.lang.ClassNotFoundException e){
System.err.println("SqlConn():"+e.getMessage());
}
}

public ResultSet executeQuery(String sql){
try{
conn = DriverManager.getConnection(url,user,password);
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery(sql);
}catch(SQLException ex){
System.err.println("SqlConn.executeQuery:"+ex.getMessage());

}
return rs;
}
public void executeUpdate(String sql){
try{
conn = DriverManager.getConnection(url,user,password);
stmt = conn.createStatement();
stmt.executeUpdate(sql);
stmt.close();
conn.close();
}catch(SQLException ex){
System.err.println("SqlConn.executeUpdate:"+ex.getMessage());
}
}

public void closeStmt(){
try{
stmt.close();
}catch(SQLException e){
e.printStackTrace();
}
}

public void closeConn(){
try{
conn.close();
}catch(SQLException e){
e.printStackTrace();
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub

}

}
2.login.jsp
<%@ page language="java" import="jav