none
Login failed for user 'domain\username' RRS feed

  • Question

  • Hi,  I'm noob at this and I'm trying to connect a SQL database with Java using jdbc but im getting this error

    com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'PHS-DX\cesachav'.
        at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
        at com.microsoft.sqlserver.jdbc.IOBuffer.processPackets(Unknown Source)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.processLogon(Unknown Source)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(Unknown Source)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(Unknown Source)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
        at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnectionInternal(Unknown Source)
        at com.microsoft.sqlserver.jdbc.SQLServerData|#]

    I was thinking on making a simple user on the database but I can't do it without the domain...(Windows authentication...)

    I have set the SQL server for mixed mode SQL and windows authentication.  but I can only access the server if I use the Windows mode, since I dont have any username or password to enter with SQL authentication.
    Also I tried putting exceptions on the windows firewall. enabled SQL server browser with no results whatsoever.

    Im using SQL Server 2005 SP2 express edition.

    the database is on my machine, locally.

    so my question is the following: Does anyone know a default username and pass to get trough the SQL authentication? or a possible soluttion for this issue... thanks
    Thursday, January 8, 2009 4:31 PM

Answers

  • If you have admin access, try to login using windows authentication mode, create a new SQL Server login and provide necessary permissions to the databases and then use the login in the connection string to connect to the database. You can make use of CREATE login syntax as shown here.

    - Deepak

    Deepak | Mark the answers if it helps to solve your problem |
    Thursday, January 8, 2009 5:26 PM
    Moderator
  • If its possible can you use database parameter in the connection string to point to the right database.
    Does your ID has sysadmin privilege? It looks like the connection string is pointing to a database where your ID doesnt have access to it.

    Vidhya Sagar. Mark as Answer if it helps!
    • Marked as answer by Ceschamo Monday, January 19, 2009 8:44 PM
    Monday, January 19, 2009 9:25 AM
    Moderator

All replies

  • If you have admin access, try to login using windows authentication mode, create a new SQL Server login and provide necessary permissions to the databases and then use the login in the connection string to connect to the database. You can make use of CREATE login syntax as shown here.

    - Deepak

    Deepak | Mark the answers if it helps to solve your problem |
    Thursday, January 8, 2009 5:26 PM
    Moderator
  • first of all I think you need to try to connect to your sever using sql server management studio to see if you can make it using that user. and the management studio will telll you more about the issue.
    Friday, January 9, 2009 3:06 AM
  • I can connect using the management studio, I wont ask for password because its on Windows authentication mode, so I guess the password is the same I use to login to my computer every day. 
    Also tried creating SQL sever login but I got same problem when trying to connect Glassfish, maybe problem its on that side
    Sunday, January 11, 2009 5:22 AM
  • Have you tried to use your new created SQL Server login to connect to SQL Server via SSMS? You should make sure your new created login works well before using it in java application.

    Wednesday, January 14, 2009 6:07 AM
  • See if you can telnet to the server:
        e.g telnet mydbserver 1433

    If you get connection denied then you probably have a connectivity issue. If you are able to connect then perhaps you have a JDBC issue.

    Your probably already checked this but, are remote connections enabled in Surface Area Configuration?
    Friday, January 16, 2009 6:03 PM
  • If its possible can you use database parameter in the connection string to point to the right database.
    Does your ID has sysadmin privilege? It looks like the connection string is pointing to a database where your ID doesnt have access to it.

    Vidhya Sagar. Mark as Answer if it helps!
    • Marked as answer by Ceschamo Monday, January 19, 2009 8:44 PM
    Monday, January 19, 2009 9:25 AM
    Moderator
  • It seemed that the sysadmin privilege was the issue, I can Ping the Database now from the glassfish interface.
    thanks to all for all the help provided.

    Monday, January 19, 2009 8:46 PM
  • Also I accomplished to log in using Windows Authentication mode by checking this http://msdn.microsoft.com/en-us/library/ms378428.aspx


    it seems I was missing the sqljdbc_auth.dll

    Monday, January 19, 2009 9:08 PM