Why my Java project doesn't see my jTDS database driver

235 views Asked by At

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

0

There are 0 answers