I am using sqljdbc4.jar in the Build path of eclipse project. I am trying to connect to SQL Server 2008 in a java program
Class.forName("com.microsoft.sqlserver.jdbc.S开发者_开发知识库QLServerDriver");
String connectionUrl = "jdbc:sqlserver://localhost:1433;" +
"databaseName=sis;user=sample;password=sample;";
connection = DriverManager.getConnection(connectionUrl);
But I am getting the following error. The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect
I tried the following
Firewall off
Enabled TCP/IP in SQL Server configuration manager --> CLient protocols
SQL Server browser service is also running Please let me know what other things should I try.
Thanks
Firewall off which way, this way??? open/enable port localhost:1433
run cmd and paste
netsh firewall set portopening protocol = TCP port = 1433
name = SQLPort mode = ENABLE scope = SUBNET profile = CURRENT
2/ change Sql Server authentication from
Windows authe... to Sql Server and Windows authentification (Mixed mode)
3) your version is SQL Server 2008 or SQL Server 2008 Express, if Express, then search on downloaded package (contains excelent help inc examples) how to connect Express on Localhost, there is difference localhost\sqlexpress
here and here and here
4) no idea how to connected, there are TCP/IP and Names Pipes too
EDIT:
5) in Management Studio you have to add new User (SQL autenthification) and assign to the decision Database (whatever or Model too) is there ??? aren't you
精彩评论