2014-02-25 167 views
0

我已經完成了在新環境中設置MySql所需的一切,我總是成功地將它轉移到另一臺PC。但現在有一個錯誤,該錯誤表示:通過JSP連接到MySql時出錯

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; 

     %> 
+0

你有更多的堆棧跟蹤共享? –

+1

請學習使用servlet。 :-) –

+0

刪除;從進口 – Leo

回答

0

您需要到MySQL連接器jar添加到類路徑的Web應用程序,所以可能只是罐子複製到WEB-INF/lib文件夾。

我試着重新創建一些頁面,併爲缺少的jar獲得了500個 - 之後 - 連接可用,但是我沒有真正運行語句,因爲你的問題從來沒有那麼遠。