sqljdbc JDBC Driver Connection URL String

Q

What is the correct format sqljdbc JDBC Driver Connection URL string? I am getting exceptions when calling the DriverManager.getConnection(url) method.

✍: FYIcenter.com

A

When you are calling the DriverManager.getConnection(url) method to establish a connection to a SQL Server database through the sqljdbc JDBC driver, you have to provide the connection URL string as the input in a correct format:

jdbc:sqlserver://<server>[:<port>][\<instance>]
   [;<property>=<value>[;...]]

Here is the explanation of different parts in the connection URL string:

  • <server> - The value must be the server name, with domain name if needed, where the database service is running. You can also use IP address of the server too.
  • <port> - The value should be the port number where the database server is listening to connection requests. This part is optional. If not specified, the sqljdbc driver will use the default value: 1433 for SQL Server, or 7100 for Sybase. Do not use port number, if instance name is used.
  • <instance> - The value should be the SQL Server instance name that to be converted to the port number by the SQL Server Browser service. The resulting port number will be used to the specified SQL Server instance. Do not use instance name, if port number is used.
  • <property>=<value>[;...] - This part is optional, except "user" and "password", which are required if you are using SQL Server authentication. You can use it to specify a list of property values to change their default values supported by sqljdbc JDBC driver.

 

Examples for sqljdbc - JDBC Driver for SQL Server

⇒⇒FAQ for sqljdbc - JDBC Driver for SQL Server

2017-01-05, 291👍, 0💬