Java can't connect to named instance of SQL server 2005

Posted on 2008-11-19
Last Modified: 2013-11-23

I'm having an issue connecting to a named instance of SQL Server 2005 from within a Java program.
I'm issuing the following command:

if( dbtype.equals("ora") )
{ new );
if( dbtype.equals("sql") )
{ new Packages.mks.frame.sql.jdbc.mssql.Driver() );
con = new url, dbuser, dbpass );
con.setTransactionIsolation( java.sql.Connection.TRANSACTION_READ_COMMITTED );

The variable "url" is set to:

When I run the command, I get the following exception:
      java.sql.SQLException: Unknown server host name 'cgcsqldev\sql2005'.

I've been reading that Java doesn't like named instances of SQL server. The identified solution was to use the default instance and specify a port number since, technically, each instance should be running on its own port. However, this is not the case at the client that I am at right now. All instances (named and default) are listening on port 1433.

Is there any way for me to connect to a named instance of SQL Server 2005 through Java without requiring that it use a different port?

Thanks a lot.
Question by:ilakic
    LVL 20

    Accepted Solution

    No. but you can find out witch port your named instance is using.

    Fire up 'SQL Server Configuration Manager' and from there its easy. Now connect using this port.

    LVL 31

    Expert Comment

    by:James Murrell

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
    Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
    Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now