Estou tentando mas não consigo Conectar o Java com o SQL SERVER 2017
Segue o código:
package loja_virtual;
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException;
public class TestaConexao {
public static void main(String[] args) throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException {
String url =
"jdbc:sqlserver://localhost:1433;" +
"databaseName=master;integratedSecurity=true;" +
"encrypt=true; trustServerCertificate=false;" +
"trustStore=storeName;trustStorePassword=storePassword;" +
"hostNameInCertificate=hostName";
Connection com = DriverManager.getConnection(url, "sa", "1234");
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
com.close();
}
}
Segue o DRIVER: sqljdbc_11.2\ptb\mssql-jdbc-11.2.0.jre17.jar