File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Just installed MS SQL Server 5 Express. JDBC connection failing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Just installed MS SQL Server 5 Express. JDBC connection failing" Watch "Just installed MS SQL Server 5 Express. JDBC connection failing" New topic
Author

Just installed MS SQL Server 5 Express. JDBC connection failing

michael tall
Ranch Hand

Joined: Nov 02, 2008
Posts: 61
I installed MS SQL Server 5 Express. Downloaded sqljdbc.jar and added it to classpath. Trying to connect to a table with 5 rows as a test.
When I run the program it is generating the following error: The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect". I, then, tried by replacing localhost with IP address 111.11.11.11. Got the same error message. Any idea what mistake I'm making?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

By default, SQL Server does not allow remote connections over TCP/IP. Check you have enabled this via the network configuration tool.
[ November 05, 2008: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
michael tall
Ranch Hand

Joined: Nov 02, 2008
Posts: 61
Between my first post on this matter and now I checked some internet resources and enabled the TCP/IP using configuration manager. I restarted SQL server and re-ran the program. Still getting the same error
michael tall
Ranch Hand

Joined: Nov 02, 2008
Posts: 61
Friends! I got it. Port in the SQL Server is different. I corrected port number in my code and connection succeeded. Thanks
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Glad to hear it
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Just installed MS SQL Server 5 Express. JDBC connection failing
 
Similar Threads
SQLServerException: TCP/IP connection to the host has failed.
Problems regarding MS JDBC Driver and JTDS-JDBC Connectivity for MS SQL Server 2000
Can't connect to SQL server 2005
SQL Server - netbeans Connection problem
Connect to MS SQl Server