我有用于从JavaFx应用程序连接到数据库的类
public class DBConnection {
public static Connection mcConnection() {
Connection connection = null;
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url = "jdbc:sqlserver://localhost; databaseName=McQueen_db;";
connection = DriverManager.getConnection(url);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return connection;
}
}
当我尝试连接时,我有一个例外情况
com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host port 1433 has failed. Error: "null. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.".
我检查了防火墙及其状况。我也认为那个港口。有什么问题吗?