日期:2014-05-18  浏览次数:20812 次

JavaBean连接mysql总是出HTTP-500错误
各位帮忙看看啊,我有几个这种程序都是这一种错误,郁闷几天啦!!!

jsp程序如下:
<%@   page   contentType= "text/html;   charset=gb2312 "   language= "java "   import= "java.sql.* "   errorPage= " "   %>
<jsp:useBean   id= "DBconn1 "   scope= "page "   class= "NewsVersion.MySQLconn "/>
<html>
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 ">
<title> 无标题文档 </title>
</head>

<body>
<%
String   String_SQL= "select   *   from   book ";
ResultSet   rs=DBconn1.executeQuery(String_SQL);
String   usercontent;
if(rs.next())
{
usercontent=rs.getString( "about ");
}
out.print(usercontent);
%>
</body>
</html>

Bean程序如下:

package   NewsVersion;
import   java.sql.*;
public   class   MySQLconn   {
String   DBDriver   =   "org.gjt.mm.mysql.Driver ";
String   ConnStr   =   "jdbc:mysql://localhost:3306/bookstore?user=root&password=200000&useUnicode=true&characterEncoding=8859_1 ";
Connection   conn   =   null;
ResultSet   rs   =   null;
public   MySQLconn(){
try{
Class.forName(DBDriver);
//加载数据库驱动程序
          }
catch(java.lang.ClassNotFoundException   e)   {
System.err.println( "MySQLconn():   "+e.getMessage());
                                                                                    }
                                }
public   ResultSet   executeQuery(String   sql){
//以记录集为返回值的函数
rs   =   null;
try   {
conn   =   DriverManager.getConnection(ConnStr);
//与DBMS建立链接
Statement   stmt   =   conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs   =   stmt.executeQuery(sql);
}
catch(SQLException   ex)   {
System.err.println( "aq.executeQuery: "+ex.getMessage());
}
return   rs;
}
}

错误提示:

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:   /dbBean4/1.jsp(3,0)   The   value &