Kerberos and Integrated Security using jTDS Driver

Up till now we were using MS JDBC Driver 4.0 to connect to SQL Server 2008 using Integrated Security and Java Kerberos and everything was working fine.

Here is the code:

Spring Context:

<!-- ***** Data Source Configuration ***** -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
    <property name="driverClassName" value="" />
    <property name="url"
        value="jdbc:jtds:sqlserver://<serverName>:<port>;databaseName=<DBName>;integratedSecurity=true;authenticationScheme=JavaKerberos; />
    <property name="initialSize" value="5" />
    <property name="maxActive" value="2" />
    <property name="defaultAutoCommit" value="false" />

<!-- ***** Transaction Manager ***** -->
<bean id="txManager"
    <property name="dataSource" ref="dataSource" />
<tx:annotation-driven transaction-manager="txManager" />

<!-- ***** JDBC Configuration ***** -->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
    <constructor-arg type="javax.sql.DataSource" ref="dataSource" />

login.conf File: { required

krb5.conf File:

    default_realm =
    dns_lookup_realm = false
    dns_lookup_kdc = true
    ticket_lifetime = 1s
    forwardable = yes
    #udp_preference_limit = 1

[realms] = {
      kdc =
      default_domain =

[domain_realm] =

    krb4_convert = true
    krb4_get_tickets = false

We were passing following arguments while running the Project:"C:\login.conf""C:\krb5.conf

Now, we decided to use jTDS instead of MS JDBC Driver and I made following changes in the above configuration:

  1. Changed Driver class from to net.sourceforge.jtds.jdbc.Driver
  2. Changed Connection String from jdbc:sqlserver://... to jdbc:jtds:sqlserver://...
  3. Added jTDS JAR and NTLM Authentication DLL File(s) to the Classpath

But it is giving me the following error:

Exception in thread "main" org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (I/O Error: GSS Failed: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt)) at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory( at org.apache.commons.dbcp.BasicDataSource.createDataSource( at org.apache.commons.dbcp.BasicDataSource.getConnection( at Caused by: java.sql.SQLException: I/O Error: GSS Failed: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt) at net.sourceforge.jtds.jdbc.TdsCore.login( at net.sourceforge.jtds.jdbc.JtdsConnection.( at net.sourceforge.jtds.jdbc.Driver.connect( at org.apache.commons.dbcp.DriverConnectionFactory.createConnection( at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject( at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory( at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory( ... 3 more Caused by: GSS Failed: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt) at net.sourceforge.jtds.jdbc.TdsCore.sendMSLoginPkt( at net.sourceforge.jtds.jdbc.TdsCore.login( ... 9 more

Things I have already tried:

  1. Tried appending useKerberos=true; and useNTLMv2=true; to the Connection String
  2. Tried appending to the Connection String

But it does not seems to be working. I tried searching on internet but could not find any solution.

Would appreciate if someone could help me out.


After searching and trying different combinations and looking at the source code of jTDS this is what finally worked for me.

  1. Use property useKerberos=true in the Connection String


  2. Pass VM Argument

So, finally after applying the above changes my Connection String looked like below:


Arguments List:"C:\login.conf""C:\krb5.conf

Need Your Help

Any tools to generate test data in database

c# database sql-server-2008 testing

I need to generate data in a database to test lucene. If anyone knows where I can get a sample database all a way to generate real life data please let me know.

protect ajax jquery

jquery ajax codeigniter

I use this to check in my registration page, if the email already exists on my database: