• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1186
  • Last Modified:

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

Hi

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") )
{    Packages.java.sql.DriverManager.registerDriver( new Packages.mks.frame.sql.jdbc.oracle.Driver() );
}
if( dbtype.equals("sql") )
{    Packages.java.sql.DriverManager.registerDriver( new Packages.mks.frame.sql.jdbc.mssql.Driver() );
}
con = new Packages.java.sql.DriverManager.getConnection( url, dbuser, dbpass );
con.setTransactionIsolation( java.sql.Connection.TRANSACTION_READ_COMMITTED );

The variable "url" is set to:
jdbc:jtds:sqlserver://cgcsqldev\\sql2005:1433/Ticket_System

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.
0
ilakic
Asked:
ilakic
1 Solution
 
Marten RuneCommented:
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.

/Marten
0
 
James MurrellProduct SpecialistCommented:
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now