Opening the SQL "database" with the given login is not possible when utilizing Windows authentication without a username and password.

Arivazhagan A 0 Reputation points
2024-07-03T11:40:23+00:00

Machine A and Machine B are the two machines I own. My Java-based application server is on machine A, while my SQL server is on machine B. Both computers are logged in as the same domain user, Administrator, and are part of the 'TEST' domain. Machine B has SQL server installed, and it is logged in to services.msc as domain user. I want to convert the database on my application server to SQL with Windows authentication without having to provide the login and password up front. I have migrated my DB into SQL and created new database in SQL. However, a lack of permission prevented the database from opening upon server launch, and the following exception was encountered.

com.microsoft.sqlserver.jdbc.SQLServerException: Cannot open database "dbname" requested by the login. The login failed

The domain username has been added to SQL Server Security ->login, and the user has been mapped to the database. Despite having DBOwner, public, and administrative permissions provided, the problem persisted. Please, someone assist me in solving this. TIA.

my connection string - jdbc:sqlserver://MachineB:1433;databaseName=DBName;Domain=TEST;integratedSecurity=true;ssl=request

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,558 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,840 questions
{count} votes

1 answer

Sort by: Most helpful
  1. LucyChenMSFT-4874 4,015 Reputation points
    2024-07-04T03:25:09.7433333+00:00

    Hi @Arivazhagan A ,

    Thank you for your reaching out and welcome to Microsoft Q&A!

    In addition to check out Erland's comment, please refer to this official document, hope this can help you well!

    Feel free to share your issue here if you have any concerns!

    Best regards,

    Lucy Chen


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    https://docs.microsoft.com/en-us/answers/support/email-notifications


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.