| Author |
SqlServer: Login failed for user
|
jim shirreffs
Greenhorn
Joined: Apr 18, 2005
Posts: 4
|
|
Hi, I've written a very simple jdbc login test program. And after all kinds of problems I've almost got it working. Almost, just can't seem to get past this "SQLServerException: Login failed for user xxxxx" problem. I created a test database (joms) then I created user user1 password1 (sql authenication) I added user1 to database joms. And after trying everything was unable to connect to the database. So I created user2 no password. And still I can't connect to the database. I am using SqlServer2008 on Vista, I'v got the latest jdbc (1.2) from Microsoft. Any help would be greatly appreciated. Here the connection code, (works gret with MySql, Oracle and Derby, different jdbc drivers of course) Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance(); conn=DriverManager.getConnection("jdbc:sqlserver://localhost;databaseName=joms;user=user2"); Here's the Exception Exception: Unable to get connect com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'user2'. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source) at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(Unknown Source) at com.microsoft.sqlserver.jdbc.TDSParser.parse(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(Unknown Source) at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source) at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(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.SQLServerDriver.connect(Unknown Source) at java.sql.DriverManager.getConnection(DriverManager.java:582) at java.sql.DriverManager.getConnection(DriverManager.java:207) Unfortunately I am now dead in the water until some kind SqlServer Guru or Jdbc Guru take pity on me and helps me out. thanks in advance.
|
 |
Rene Larsen
Ranch Hand
Joined: Oct 12, 2001
Posts: 1177
|
|
Does your SQL Server have an instanceName?? If yes than you maybe need to add the property 'instanceName=SOME_INSTANSE_NAME' to your connect URL. Maybe you can logon with your windows user/password?? If this is the case, then you can add the property 'integratedSecurity=true' to the connect URL instead of 'user=xxx;password=yyy' Or maybe you need to add the database port number to the URL?? (default port is 1433) [ August 09, 2008: Message edited by: Rene Larsen ]
|
Regards, Rene Larsen
Dropbox Invite
|
 |
jim shirreffs
Greenhorn
Joined: Apr 18, 2005
Posts: 4
|
|
Thanks for the reply, tried most of what you suggested, no go, I think the jdbc is working since the error message ("SQLServerException: Login failed for user 'user2'") is from SqlServer and not jdbc. I wish I could find something like Oracle's sqlPlus. Then at least I could find out if I did everything I needed to do to allow user2 access to database joms. I am going to try your suggestion on using a windows user account and see what that does. thanks again jim
|
 |
Victor Emanuel
Greenhorn
Joined: Oct 25, 2009
Posts: 1
|
|
The solution for me was changing SQLServer's authentication mode from "Windows Authentication" to "Windows and SQLServer Authentication"
You can do that by the following:
1) in SQL Server Management Studio, right click on the server name (the root of that tree in Object Explorer, left part of the screen)
2) click properties
3) click security
4) select "Windows and SQLServer Authentication"
|
 |
Carlos Lacerda
Ranch Hand
Joined: Apr 09, 2003
Posts: 34
|
|
|
Carlos Lacerda, Brasil
[SCJP 1.4-5.0] [SCJD] [SCWCD] [SCEA] [OCA-OAS 10g]
|
 |
 |
|
|
subject: SqlServer: Login failed for user
|
|
|