为什么我的Java项目不参见我的JTDS数据库驱动程序

发布于 2025-02-03 05:23:45 字数 789 浏览 4 评论 0原文

我正在尝试与SQL Server Local数据库连接,我从Intellij级别成功地连接了它,并且有信息需要安装JTDS驱动程序来使用它。我下载了它的最新版本,并从项目中的lib dir中添加为库,尽管Java说它找不到课程,也许我安装了错误?这是我的代码

import java.sql.*;

public class Main {
    public static void main(String [] args) throws ClassNotFoundException, SQLException {
        Class.forName("net.sourceforge.jtds");
        Connection connection = DriverManager.getConnection("jdbc:jtds:sqlserver://./TPO");
        Statement statement = connection.createStatement();
        String sqlString = "SELECT * FROM Books";
        ResultSet resultSet = statement.executeQuery(sqlString);
        while (resultSet.next()) {
            System.out.println(resultSet.getString(1));
        }
    }
}

“错误输出”

I'm trying to connect with SQL Server local database, I connected with it successfully from IntelliJ level, and there was information that I need to install jTDS driver to use it. I downloaded latest version of it and added as a library from my lib dir in project, despite this java says that it couldn't find the class, maybe I installed it wrong? Here is my code

import java.sql.*;

public class Main {
    public static void main(String [] args) throws ClassNotFoundException, SQLException {
        Class.forName("net.sourceforge.jtds");
        Connection connection = DriverManager.getConnection("jdbc:jtds:sqlserver://./TPO");
        Statement statement = connection.createStatement();
        String sqlString = "SELECT * FROM Books";
        ResultSet resultSet = statement.executeQuery(sqlString);
        while (resultSet.next()) {
            System.out.println(resultSet.getString(1));
        }
    }
}

Error output

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

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

发布评论

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