通过JSP连接到MySql时出错

时间:2014-02-25 20:21:03

标签: java mysql jsp

我已经完成了在新环境中设置MySql所需的一切,我总是成功将其转移到另一台PC。但现在有一个错误,错误说:

HTTP Status 500 - An exception occurred processing JSP page /include/database.jsp at line 4

--------------------------------------------------------------------------------

type Exception report

message An exception occurred processing JSP page /include/database.jsp at line 4

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

exception 
    org.apache.jasper.JasperException: An exception occurred processing JSP page /include/database.jsp at line 4

    1: <%@ page import="java.sql.*;" %>
    2: 
    3: <%
    4: Connection con=DriverManager.getConnection("jdbc:mysql://localhost/bms", "root","");
    5: 
    6: Statement stmt=con.createStatement();
    7: Statement stmt1=con.createStatement();

    This is the whole code:
        <%@ page import="java.sql.*;" %>

        <%
        Class.forName("com.mysql.jdbc.Driver");
        Connection con=DriverManager.getConnection("jdbc:mysql://localhost/bms", "root","");

         Statement stmt=con.createStatement(); 
         Statement stmt1=con.createStatement();
         Statement stmt2=con.createStatement();
         Statement stmt3=con.createStatement();
         Statement stmt4=con.createStatement();
         Statement stmt5=con.createStatement();

         ResultSet rs,rs1,rs2,rs3,rs4,rs5;

         PreparedStatement pstmt,pstmt1,pstmt2,pstmt3,pstmt4,pstmt5;

         %>

1 个答案:

答案 0 :(得分:0)

您需要将MySQL连接器jar添加到Web应用程序的类路径中,因此可能只需将jar复制到WEB-INF / lib文件夹中。

我试图重新创建你的一些页面,并为丢失的jar获得500 - 之后 - 连接可用,但我实际上没有运行语句,因为你的问题从来没有那么远。