skip to main content
Using the driver : Connecting to named instances
  

Try DataDirect Drivers Now

Connecting to named instances

Microsoft SQL Server supports multiple instances of a 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");