SQL Server Express に接続したい。このドライバーをダウンロードしました。ヘルプ ファイルを読みましたが、これが私のコードです。
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://localhost;database=ActorsDb;integratedSecurity=true;";
Connection con = DriverManager.getConnection(connectionUrl);
PreparedStatement st = con.prepareStatement("INSERT INTO Actors(FirstName,LastName,Age) VALUES(?,?,?)");
st.setString(1, "Robert");
st.setString(2, "de Niro");
st.setInt(3,45);
st.executeUpdate();
con.close();
}
catch (SQLException | ClassNotFoundException e)
{
e.printStackTrace();
}
私はこの例外を受け取ります:com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
ファイアウォールをオフにしましたが、何も変わりませんでした。
SQL Server 構成マネージャーに移動し、TCP/IP を有効にしました
IPアドレス、IP1に行き、プロパティを設定しました
アクティブ: はい; 有効:はい; TCP 動的ポート:[空] ; TCP ポート:1433
私が欠けているもののヒントはありますか?ありがとう。