I have a new local sql server database, running hypothetically on port 48000. In SQL Server Management Studio under the name of the computer\MSSQLSERVER01, Security, Logins I clicked sa, properties and set the password. I have created a database, mystuff. sa is not listed under security under mystuff. I have the connection string jdbc:sqlserver://MYDESKTOP\MSSQLSERVER01:48000;databasename=mystuff;user=sa;password=123 but I get "Login failed for user 'sa'" when I attempt to connect. What else do I need to do to setup sa? Something under mystuff?

  • sa kind of owns everything and can do pretty much anything on a SQL Server instance, so you don't need to give it any privileges other than enable it to login (a basic test: can you login with sa from management studio?
    – Ronaldo
    Apr 26, 2021 at 15:05
  • you should add a new user and give him enough rights.
    – nbk
    Apr 26, 2021 at 16:15
  • Can you get the error message form the SQL Server error log, including the error number & state as this will provide more info on the root cause.
    – HandyD
    Apr 27, 2021 at 5:30

1 Answer 1


You should not be connecting any application to your database installation using the installation owner account ("sa"). Instead, create an account dedicated for the use of your Application and grant that account the right privileges.

Always keep the biggest and best tools in the box for yourself, because it's your job to clean up the "mess" made by everyone (and everything) else!

If an application connects with an "overpowered" account, like "sa"' and that application gets hacked, then your database can be wrecked in all sorts of nasty, painful and expensive to recover ways!
Save yourself the grief.

  • I understand what you are saying. this is on a development computer and I'm the only user
    – Chris94
    Apr 26, 2021 at 21:52
  • in any case I still can't log in with jdbc and sa using my connect string and I would like to understand why
    – Chris94
    Apr 26, 2021 at 21:53
  • I /think/ the default Authentication Mode for SQL Server only allows [the more secure] Windows Authentication, not the SQL Server Authentication that you're trying to use here. You'd have to reconfigure SQL Server into Mixed Mode to allow it. Not that you necessarily should. It may be better to have your client application use a "trusted" connection, so that it "passes through" the active, Windows user. Connecting from an Application using the "sa" account, even on a single-user, development machine is still a really Bad Idea.
    – Phill W.
    Apr 27, 2021 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.