3
votes

Unable to connect with sql server with servlet.

its on tomcat 7 which says

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection ("jdbc:sqlserver://;integratedSecurity=true");

Getting error: com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'MYDOMAIN\SUMIT-PC$'.

SUMIT-PC is my computer's name. it should be 'MYDOMAIN\SUMIT SINGH'

2
Is your service running as "Local Machine" account? If so, let it run as a dedicated user. See here for a related question.Christian.K

2 Answers

4
votes

This means that your tomcat is running under LocalSystem account in domain-based network. If you want to make tomcat to use your login propagation - you should to tune up it to impersonate logged on user and your tomcat and sql server(or workstation for windows 2003 domains) should be trusted for delegation on domain level, and user MYDOMAIN\SUMIT SINGH should be also not denied for delegation on domain level.

or

implement your own impersonation inside the server process - this requires you to know user's password

1
votes

Today I got the same issue. In my machine, it was Tomcat 8.5 and I have installed tomcat as a windows service. (installed using apache-tomcat-8.5.40.exe)

Press the Win + R keys on your keyboard, to open the Run window. Then, type services.msc and hit Enter or press OK.

enter image description here

Right click on Tomcat service and select Properties. In that dialog box go to Log On tab and select This Account under Log on as option. Fill your username, password as well. Then click OK.

Then restart the service!!!