0

I have been struggling since morning in order to try to connect my java web application to the database which is on a different system (using windows auth).

I managed to access it from my SSMS, I went to windows credentials manager and created the same credentials as of other system where the SQL server is installed, below are the details:

enter image description here

Now when I use the IP(192.168.2.172) in SSMS as a server name then I am able to connect using windows auth but can not access the same from my Java web app. I am using jtds with the below string but its not working. Please help

<property name="url" value="jdbc:jtds:sqlserver://192.168.2.172:1433/realtime;useNTLMv2=true" />

I am constantly getting this error:

Caused by: java.sql.SQLException: Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.
        at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:372)
        at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2988)
        at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2421)
        at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:649)
        at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:371)
        at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
        at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
        at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
        at org.apache.commons.dbcp.BasicDataSource.valida
Talib
  • 1,134
  • 5
  • 31
  • 58
  • This sounds like you should be talking to your network administrator about the trust between the 2 domains. – Thom A Jan 11 '20 at 17:21
  • @Larnu thanks for the response, but how come SSMS is able to connect if it is the network issue? – Talib Jan 11 '20 at 17:21
  • Then is Java running under credentials from a different domain? – Thom A Jan 11 '20 at 17:22
  • @Larnu you mean Java installed on my machine? I think this should be using my system credentials or is there a way to check that? – Talib Jan 11 '20 at 17:23
  • set the domain in the connstring https://stackoverflow.com/questions/3682852/sql-server-connect-with-windows-authentication – lptr Jan 11 '20 at 21:21

1 Answers1

0

The Microsoft JDBC Driver for SQL Server supports Windows Auth through Kerberos on all platforms, and on Windows using Kerberos or NTLM using the Type 2 authentication dll: Connecting with integrated authentication On Windows.

David Browne - Microsoft
  • 80,331
  • 6
  • 39
  • 67