Skip to main content

Java - Windons Authentication to SQL Server with jTDS Driver


To make jTDS driver to work with your SQL server windows authentication use below jdbc url format.

1. windows authentication without SSO

jdbc:jtds:sqlserver://<HOSTNAME>:1433;instance=SQLEXPRESS;databaseName=lportal;domain=<domain>;user=<user>;password=<password>


2. windows authentication with SSO

jdbc:jtds:sqlserver://<HOSTNAME>:1433;instance=SQLEXPRESS;databaseName=lportal;domain=<domain>

and set the java argument something like this to load ntlmauth.dll 

 -Djava.library.path="<driver-folder>/windowsSSO"


Note : if you are installing sqlexpress/sql server on your desktop or server you need to enable tcp/ip connectivity to the instance.

Steps to enable tcp/ip connectibity:

1. Open SQL Server Configuration Manager

2. Goto Configuration Manager > SQL Server Network Configuration > Protocols for <instancename>

3. Right click on TCP/IP and select enable.




Comments

Popular posts from this blog

Testing Restful API with Spock - groovy

Spock is a testing and specification framework for Java and Groovy applications. Here we will use groovy RestClient along with Spock to test Restful Services. import groovyx.net.http.RESTClient import spock.lang.Specification import spock.lang.Shared class MyApiSpec extends Specification { @Shared RESTClient restClient def setupSpec() {                 restClient = new RESTClient('hostnamewithport') restClient.handler.failure  = restClient.handler.success }  def 'test get method'(){  given:  restClient.headers.Accept = 'application/json'  when:  def resp = restClient .get(path: 'path(ex:/api/list/'), query:[param1:'param1value',param2:'param2value'] )  then:  resp.status == 200  resp.data.somejsonobject == 'expectedjson'  }  def 'test post method'(){  given:  restClient .headers.Accept = 'appli...