aspose file tools*
The moose likes JDBC and the fly likes Can't connect to SQL server 2005 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Can Watch "Can New topic
Author

Can't connect to SQL server 2005

James Lee
Ranch Hand

Joined: Oct 16, 2006
Posts: 36
Hi all,

I used MS SQL server 2005 and tried to connect to it but failed. The error happened in making the connection. Can anyone give a hand?

JDBC code

Error:
[BOLD]db:com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect[/BOLD].

When I installed the SQL server, I chose default so no username/password are needed. The server is on my local computer. I also copied the driver jar to TOMCAT's lib folder and the classpath.

Many thanks.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

Is the server configured to allow TCP/IP connections?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
James Lee
Ranch Hand

Joined: Oct 16, 2006
Posts: 36
Hi Rob,

I have not done any configurations so everything is by default. Could you tell me where it should be done?

Many thanks.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

You can find these settings under Configuration Tools | SQL Server Configuration Manager in the SQL Server start menu folder.
Arvind Mahendra
Ranch Hand

Joined: Jul 14, 2007
Posts: 1162
go to SQLServer manager ,click on sqlserver 2005 network configuration, double click on 'protocol for <yourservername>', right click on TCP/IP choose properties, on the protocol tab choose enabled to Yes and on the IP address tab make sure its on port 1433.


I want to be like marc
Shawn Stark
Greenhorn

Joined: Jan 02, 2008
Posts: 7
Yes set all your settings for your IP Address and stuff properly then from
ODBC data source administrator in adminastrative tools, select the system DSN tab. SQL server is at the bottom of my list. After that select you type your server name now your driver will be detected
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can't connect to SQL server 2005