Monday, March 26, 2012

Named Instance of SQL Server in Java

I have a java compiled jar file, which accept the connection string as follows: -Uusername -Ppassword -Sservername:port

This string works fine with the default instance of SQL Server, I mean as long as you supply the name of the SQL Server as 'SQLServer', but if I want to run it against the named instance of SQL Server like 'SQLSERVER\NamedInstance' then the connection is failing, giving me the unknown host error. Any idea why?I've got this connection string

driver={SQL Server};server=MachineName\Mercure;uid=sa;pwd=pwd

I've created the instance name during the installation of MSDE
and it seems that SQL Server was installed with the computer name

ONLINE HELP

Computer Name
The Computer Name dialog box in Setup allows you to install Microsoft SQL Server 2000 on your local computer, on a remote computer, or on a virtual server.

All options for installing and upgrading are available on the local computer. Advanced options, including registry rebuild, unattended installation, and upgrading to a cluster are not available on a remote installation. If you are running Setup on a clustered computer, the Virtual Server option is available.

Options
Local Computer

By default, the name in the edit box is the local machine name, that is, the computer on which Setup is running. For a local installation, accept the default and click Next.

Note If you are installing tools only, Local Computer will be the only option available on this dialog box.

Remote Computer

Enter a computer name for a remote installation, or click Browse to locate the remote computer.

Virtual Server

Enter the name of a new or existing Virtual SQL Server to manage.

This option is available only when Microsoft Cluster Service (MSCS) is detected on an Windows NT or Windows 2000 Enterprise operating system.

Browse

Click the Browse button to locate a remote computer.

This button is available only when the Remote Computer option is selected.|||What JDBC driver are you using? If it's Microsoft's then it does support named instances. I think this was introduced in SP2 of the JDBC driver. Let me know and I'll post and example. If it's another jdbc driver usually you can supply the port number the instance is running in the connection string.|||-S//MachineName/DBNAME:1599

where 1599 is the Named Instance Port numbersql

No comments:

Post a Comment