skip to main content
DataDirect Connect Drivers : Microsoft SQL Server Driver : Connecting to Named Instances
  
Connecting to Named Instances
Microsoft SQL Server 2000 and higher support multiple instances of a Microsoft SQL Server database running concurrently on the same server. An instance is identified by an instance name. To connect to a named instance using a connection URL, use the following URL format:

jdbc:datadirect:sqlserver://server_name\\instance_name
Note: The first backslash character (\) in \\instance_name is an escape character.
where:
server_name
is the IP address or hostname of the server.
instance_name
is the name of the instance to which you want to connect on the server.
For example, the following connection URL connects to an instance named instance1 on server1:

jdbc:datadirect:sqlserver://server1\\instance1;User=test;Password=secret
To connect to a named instance using a data source, you specify the ServerName property. For example:

SQLServerDataSource mds = new SQLServerDataSource();
mds.setDescription("My SQLServerDataSource");
mds.setServerName("server1\\instance1");
mds.setDatabaseName("TEST");
mds.setUser("test");
mds.setPassword("secret");