Intellij找不到mysql JDBC驱动程序

发布于 2025-02-01 14:35:23 字数 1284 浏览 4 评论 0原文

我添加了MySQL JDBC驱动程序,但我一直遇到以下错误:找不到JDBC的合适驱动程序。

这是我正在尝试的代码:

public class Test extends HttpServlet {

    public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        try {

            Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/jsp1", "root", "");
            System.out.println("Connected successfully");

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}

这是项目设置。

我添加mysql jar,就会出现以下一个问题:

“在此处输入图像说明”

我已经尝试了上面的所有三个选项,但是我一直遇到相同的错误。

I have added MySQL JDBC driver but I keep getting the following error: No suitable driver found for jdbc.

Here's the code that I'm trying:

public class Test extends HttpServlet {

    public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        try {

            Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/jsp1", "root", "");
            System.out.println("Connected successfully");

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}

Here are the project settings.

enter image description here
enter image description here

As soon as I add MySQL jar, one following problem appears:

enter image description here

I have tried all of the three options above, but I keep getting the same error.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文