jsp+javabean错误无法返回
package test;
import java.sql.*;
public class TestBean
{
private String strDrvName="com.mysql.jdbc.Driver";
private String strUrl="jdbc:mysql://localhost:3306/student?user=root&password=admin&useUnicode=true&characterEncoding=UTF-8";
private Connection conn=null;
private Statement stmt=null;
private ResultSet rs=null;
private String sql;
private String name=null;
public TestBean()
{
try
{
Class.forName(strDrvName);
}
catch (ClassNotFoundException e)
{
System.err.printf("TestBean.TestBean():"+e.getMessage());
}
}
public ResultSet ExecuteQuery(String strSQL)
{
rs=null;
stmt=null;
strUrl=null;
try
{
//连接数据库
conn=DriverManager.getConnection(strUrl);
stmt=conn.createStatement();
rs=stmt.executeQuery(strSQL);
}
catch (SQLException e)
{
System.err.println("TestBean.ExecuteQuery():"+e.getMessage());
System.out.print("false:"+e.getMessage());//输出到客户端
}
return rs;
}
public void ExecuteUpdate(String strSQL)
{
rs=null;
stmt=null;
strUrl=null;
try
{
conn=DriverManager.getConnection(strUrl);
stmt=conn.createStatement();
sql=strSQL;
stmt.execute(strSQL);
stmt.close();
conn.close();
}
catch (SQLException e)
{
//System.err.println("TestBean.ExcuteUpdate():"+e.getMessage());
System.err.println("db,excuteUpdate:"+e.getMessage());
System.out.print("false:"+e.getMessage());//输出到客户端
//throw(e);
}
}
}
数据库表结构 student_info(student_name varchar(20),student_id varchar(20) pk)
同一条记录插入两次,数据库报出了主键冲突的错误,但在jsp页面中无法看到错误,求教!!!!
showError.jsp显示错误信息,程序没有调用showError.jsp,showError.jsp调试是好的,可以显示错误。