jTDS JDBC Driver Connection URL String

Q

What is the correct format jTDS 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 jTDS JDBC driver, you have to provide the connection URL string as the input in a correct format:

jdbc:jtds:<server_type>://<server>[:<port>][/<database>]
   [;<property>=<value>[;...]]

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

  • <server_type> - The value must be 'sqlserver', if you are connecting to a SQL Server database. Or set it to 'sybase', if you are connecting to a Sybase database.
  • <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 jTDS driver will use the default value: 1433 for SQL Server, or 7100 for Sybase.
  • <database> - The value should be the database name to which the connection will be associated. This part is optional. If not specified, the database server will associate the connection to the default database. Note that a single database server can server multiple databases, and one of them will be flagged as the default database.
  • <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 jTDS JDBC driver.

 

jTDS JDBC Driver Connection Properties and Defaults

ShowJdbcDrivers.java - jTDS JDBC Driver Example

Examples for jTDS - JDBC Driver for SQL Server

⇑⇑ FAQ for jTDS - JDBC Driver for SQL Server

2017-02-03, 1855🔥, 0💬