我想連接到sql server express。 我下載了驅動程序this。 我讀了幫助文件,這是我的代碼:如何解決它:com.microsoft.sqlserver.jdbc.SQLServerException?
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
我錯過了什麼提示? 謝謝。
我想連接SQL Server與配置單元使用sqoop'[root @ SLAVENODE1 sqoop/bin]#sqoop import --connect「jdbc:sqlserver://10.23.52.15:1433; dtabase = test; username = **** ; password = ****「--table dept -m 1 --hive-import - --schema dbo',發生上述相同的錯誤。我在sqoop/lib文件夾中移動了sqljdbc4.jar。正如你所說的那樣複製sqljdbc_auth.dll。請幫助 – 2016-08-26 08:08:21