Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
168 views
in Technique[技术] by (71.8m points)

java - No suitable JDBC driver found for SQL Server

I searched a lot of solutions, but none of them can solve my problem. I created a new project like below: enter image description here

Note that I use Java 15. My main code to connect to SQL Server is below

package testDatabasePakage;

public class JavaConnectDB {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        String url = "jdbc:sqlserver://localhost:1433;databaseName=test;integratedSecurity=true;";
        
        try
        {
            Connection connection = DriverManager.getConnection(url);
            System.out.println("connected to Microsoft SQl Serever");
            
        }
        catch(SQLException e)
        {
            System.err.println("Opps,theres an error
 ");
            e.printStackTrace();
            
        }
    }

}

Then I download the JDBC driver to connect to SQL Server, and I add it to my project:

enter image description here

From here I choose the third one, because I think it is the last version that suitable for Java 15. After that, I run project and I got the result is "No suitable driver found for jdbc:sqlserver://localhost:1433;databaseName=test;integratedSecurity=true;"

Then I tried the other two, and got the same result like above. How do I add the JDBC driver suitable for my project?

question from:https://stackoverflow.com/questions/65857882/no-suitable-jdbc-driver-found-for-sql-server

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...