Can't connect to SQL Server 2005

♀尐吖头ヾ 提交于 2019-12-13 18:40:07

问题


I just installed SQL Server 2005 on my machine and now I am trying to connect to it via SQuirrel SQL, but I am unfortunately running into problems.

When installing SQL Server 2005 I chose mixed mode for authentication and I have set up a new user account with which I am trying to connect. I also have installed the Microsoft SQL Server JDBC Driver and I have successfully used SQuirrel SQL to connect to a remote server before.

Currently I am trying to connect to my database by specifying

jdbc:sqlserver://localhost:1433

for the URL and selecting Microsoft SQL Server JDBC Driver.

After entering my username and password I am getting the following error:

test: The TCP/IP connection to the host  has failed. 
java.net.ConnectException: Connection refused: connect

with the following stack trace:

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host  has failed. java.net.ConnectException: Connection refused: connect
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
    at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
    at net.sourceforge.squirrel_sql.fw.sql.SQLDriverManager.getConnection(SQLDriverManager.java:133)
    at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.execute(OpenConnectionCommand.java:97)
    at net.sourceforge.squirrel_sql.client.mainframe.action.ConnectToAliasCommand$SheetHandler.run(ConnectToAliasCommand.java:279)
    at net.sourceforge.squirrel_sql.fw.util.TaskExecuter.run(TaskExecuter.java:82)
    at java.lang.Thread.run(Unknown Source)

One last thing, I have checked to make sure TCP/IP connections and named pipes are enabled in the SQL Server Configuration Manager.

If anyone has any thoughts on my problem I would be very grateful to hear them.


回答1:


Run the surface area configuration tool from:

Start > All Programs > Microsoft SQL Server 2005 > Contifuration Tools > Sql Server Surface Area Configuration

Click on Surface Area Configuration for Services and Connections link.

In next window click on Remote Connections item under the server you want to configure. now on right hand side chose 'Local and remote connections' and then select 'Using both TCP/IP and named pipes'.

Hope this solves your problem.

EDIT: You may check these articles at microsoft.




回答2:


So after doing some more research, it turns out that my sql server was not listening to the correct port. For anyone else having this problem I recommend reading the following web page which was very useful:

http://www.databasejournal.com/features/mssql/article.php/3689846/Using-Non-Standard-Port-for-SQL-Server.htm

Basically you need to configure your server to always listen on a certain port (I chose 1433) and restart your server. After that it should work like a charm.




回答3:


I was having the same issue on a Windows 2008 R2 box w/ SQL 2005 and it ended up that I needed to open up port 1433 in the windows firewall. I had also checked to make sure remote connections were enabled.



来源:https://stackoverflow.com/questions/873924/cant-connect-to-sql-server-2005

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!