[英]Error in connecting to MySql through JSP
I have done everything that is needed in setting up MySql in a new environment, I'm always successful in transferring it to another PC. 我已经完成了在新环境中设置MySql所需的一切,我一直成功地将其转移到另一台PC上。 But now there is an error, the error says: 但是现在有一个错误,错误说:
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;
%>
You need to add the MySQL connector jar to the classpath for the web app, so probably just copy the jar into the WEB-INF/lib folder. 您需要将MySQL连接器jar添加到Web应用程序的类路径中,因此可能只需将jar复制到WEB-INF / lib文件夹中即可。
I tried to recreate some of your page and got the 500 for the missing jar - after that - the connection was available, but I didn't actually run statements because you problem never got that far. 我试图重新创建您的页面的一部分,并为丢失的jar添加了500个-之后-连接可用,但实际上并没有运行语句,因为您的问题从未解决过。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.