Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2011
    Posts
    47

    Unanswered: How to solve this SQL Exception?

    I m into my deployment stage of my Java app when I was deploying my app in one of the laptop of my client my code throws an SQL Exception saying
    Code:
    [Microsoft] [ODBC SQL Server Driver][SQL Server]
    cannot open database "bms" requested by the login. login failed.
    this is the first time i m getting this exception can any one provide me help regarding the same?
    thanks
    I M using MSSQL 2005

  2. #2
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    [bms] database was not accessible at the time. It could be that you were restoring it from the backup, and the restore process has not finished. If it was not a restore, - then in general the database could have been in recovering state, even if you were attaching it. There are measures that you can take to ensure the next deployment attempt does not result in the similar situation, but that's more details than needed at this time.
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  3. #3
    Join Date
    Sep 2011
    Posts
    47
    Quote Originally Posted by rdjabarov View Post
    [bms] database was not accessible at the time. It could be that you were restoring it from the backup, and the restore process has not finished. If it was not a restore, - then in general the database could have been in recovering state, even if you were attaching it. There are measures that you can take to ensure the next deployment attempt does not result in the similar situation, but that's more details than needed at this time.
    thanks for the reply man
    1. Yes i have restore the database, first i created a database called bms and then done the restore (through the backup copy of the same db)
    2. the restore was done successfully .
    3. when i map data source to any system db say tempdb then my application connects to that db successfully but it shows error(which i have mention in this topic) while connecting to db which I have created now.

    if you need more information then please ask me ?

  4. #4
    Join Date
    Sep 2011
    Posts
    47
    Quote Originally Posted by rdjabarov View Post
    [bms] database was not accessible at the time. It could be that you were restoring it from the backup, and the restore process has not finished. If it was not a restore, - then in general the database could have been in recovering state, even if you were attaching it. There are measures that you can take to ensure the next deployment attempt does not result in the similar situation, but that's more details than needed at this time.
    can you explain why this error is thrown?
    yesterday i did the same thing and every thing was fine
    but today I m doing the same thing on different machine but now i m getting an error
    can't understand why?

  5. #5
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Are you creating the database manually? Is RESTORE process initiated manually? You should have a script for both tasks:
    Code:
    :connect <instance_name>
    if db_id('bms') is not null
       exec ('create database [bms] ...')
    go
    restore database from ....
    go
    This way it's all consistent, no anomalies.
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Sounds like the login to the SQL instance is not mapped to the user in the bms database.

    In SSMS find the login you are using and open up the properties window. Then the user mapping tab and you can fix the issue there.

    Alternatively look up sp_change_users_login in the manual as this will be able to fix your orphaned user.
    George
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •