1

I tried to connect to Microsoft SQL Server and it gives me the error Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. ClientConnectionId:f5448d0d-950a-45b3-842f-9d2c6ac86ccd

When I run netstat -na and I found a listening with a port of 1433 but still, the connection with Java doesn't work.

My code:

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

connnectionUrl = "jdbc:sqlserver://localhost:1434;database=Northwind;integratedSecurity=true;";

con = DriverManager.getConnection(connnectionUrl);

Full stacktrace:

   com.microsoft.sqlserver.jdbc.SQLServerException: Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. ClientConnectionId:f5448d0d-950a-45b3-842f-9d2c6ac86ccd
    at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:254)
    at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:258)
    at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:104)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:4772)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3581)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:81)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3541)
    at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7240)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2869)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2395)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2042)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1889)
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1120)
    at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:700)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at jdbc.Temp.main(Temp.java:18)
Al Sweigart
  • 11,566
  • 10
  • 64
  • 92
Daniel Barzilay
  • 53
  • 1
  • 2
  • 9

3 Answers3

1

By default MS SQL Server does not listen on outside address. The following link could be helpful

https://knowledgebase.apexsql.com/configure-remote-access-connect-remote-sql-server-instance-apexsql-tools/

https://support.plesk.com/hc/en-us/articles/213407669-How-to-enable-remote-connections-to-MS-SQL-server-

Naveed Kamran
  • 453
  • 1
  • 4
  • 16
1

Solved it. it was because my PC name and Windows User was in Hebrew, changed it to English and it worked. also, check in the sql server path there aren't any folders named in Hebrew Thank you, everyone, who helped. :)

Daniel Barzilay
  • 53
  • 1
  • 2
  • 9
0

Did you follow instructions in this

Lakshan Dissanayake
  • 521
  • 1
  • 4
  • 18