I searched a lot of solutions, but none of them can solve my problem. I created a new project like below:
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:
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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…