• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SqlServer: Login failed for user

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
jim shirreffs
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic