Alex Mueller on Software and Technology 
Wednesday, May 23, 2007

SQL Server 2005 always seems to give me trouble with connection strings. When I install SQL 2005, I choose all the defaults for the developer edition. I would be just as happy using the file system as my provider, perhaps XML, but since SQL Server makes parts of my life easier, I use it. With SQL 2000, my connections strings always used "www.muellerdesigns.net." This did not work for me in 2005. I have to use serverName\instanceName.

I recently rebuilt my current development environment. In configuring all of my .NET applications, I did not pay much attention to my instance of SQL, other than noticing my server and instance names changed. When configuring my Java environment, I installed my JDBC drivers for SQL 2005, but my attempts to connect to the database were failing.

"com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host has failed. java.net.ConnectException: Connection refused: connect"

I spent some time trying to debug my Java, connection issues, and what I finally discovered is that by default, SQL Server 2005 Developer Edition does not open TCP/IP connections, unless you specifically enable them using the SQL Server Configuration Manager and SQL Server Surface Area Configuration tools. JDBC will not connect until TCP/IP for SQL Server is enabled. All of the articles I read about connecting to SQL Server with the JDBC driver dealt with connection strings and properties. They assumed my server was properly configured, but since I used all the defaults, it was not.

I use a tool called Active Ports to enable me to see what ports I currently have open. When I searched for port 1433, the default SQL port, I noticed it was not in use. I enabled it, restarted SQL Server, and was finally able to connect using JDBC.

In SQL 2005, (local) and www.muellerdesigns.net cannot be used interchangeably. (local) uses named pipes. www.muellerdesigns.net uses a UDP port on port 1434. Using the serverName\instanceName will use TCP/IP instead of named pipes. I actually had my sqlservr.exe listening on TCP 1539. Now I have it using TCP 1433 and JDBC is happy.

ConnectionStrings.com is a good resource for checking connections strings.

Wednesday, May 23, 2007 9:17:59 PM (Mountain Standard Time, UTC-07:00) | Comments [0] | Technology | Tools#
MuellerDesigns.net
Search
On This Page
The Split Personality of the Tester/Developer
Cross Site Scripting (XSS)
Creating files with FSUTIL
PowerShell Management Library for Hyper-V
Installing Windows 7
Installing Linux in Hyper-V
Internet Explorer 8 Release Candidate 1
PowerShell Documentation
Automate Daily Tasks with PowerShell
SketchPath XPath Editor
Software Testing - Revisited
Architecting Buildings and Software
NBCOlympics.com with Silverlight
Marker Interfaces and C# Attributes
Most Popular
JavaScript ReplaceAll Functionality
What is polymorphism?
What is composition?
Sorting with IComparable and IComparer
Applying the Observer Pattern in ASP.NET
MVP in ASP.NET
What is abstraction?
What is encapsulation?
What is a class?
What is inheritance?
Authentication in ASP.NET
Calendar Controls
XPathNavigator.CheckValidity new for 2.0
SQL Server 2005 Connection Issues
Auto-attach to process '[####] aspnet_wp.exe' on m...
What is an object?
FreeTextBox
VMWare and VPC
An Example of Reflection using C#
Changing File Ownership In Vista and Longhorn
Archive
Links
Categories
My Local Blog Map
Blogroll
About
Powered by:

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
MuellerDesigns.net

Sign In

Help Those In Need
The Hunger Site
Ronald McDonald House Charities (RMHC) of Western Washington & Alaska