开发者

Not able to connect local instance of SQL Server 2008 in a Java program

开发者 https://www.devze.com 2023-04-02 04:16 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消