gpt4 book ai didi

java - 通过JSP连接MySql时出错

转载 作者:行者123 更新时间:2023-11-30 00:37:39 24 4
gpt4 key购买 nike

我已经完成了在新环境中设置 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;

%>

最佳答案

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

我尝试重新创建您的一些页面,并为丢失的 jar 获取了 500 - 之后 - 连接可用,但我实际上没有运行语句,因为您的问题从未发展到那么远。

关于java - 通过JSP连接MySql时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22025285/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com