Search code examples
sql-serverjdbcjtds

jTDS connection string: connect to a MS SQL Server instance with a backslash


I am using the jTDS driver in a Java application. The database administrator told me that the SQL Server instance name is

MSSQL-DB09v1\v1

How should I write the connection URL?

I have been using something like

jdbc:jtds:sqlserver://server-name/database_name 

for some time and it works well, but don't know the right connection string when the instance name contains a backslash.


Solution

  • Did further research and tests. Found out the correct connection URL string in this case is:

    jdbc:jtds:sqlserver://server-name/database_name;instance=instance_name
    

    In my case, the connection string is:

    jdbc:jtds:sqlserver://server-name/MSSQL-DB09v1;instance=v1
    

    See jTDS FAQs for more details