• 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

JDBC Connection to MS SQL with Windows Authentication

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Environment -

I am using Tomcat as my servlet engine and IIS as the Server. Additionally, I am using MS SQL 2000 as my DB. The DB resides on a seperate machine, and have created an ODBC JDBC connection on the local machine to access it. Additionally, the authentication for the DB is set to "Windows Authentication".

Problem -

Everything works fine if I simply run tomcat and access the databse. Also, things run fine when I run tomcat via IIS too. However, when I try accessing the database, I get the error

Login failed for user '<username>'

Now, the funny part is, this username is actually the username of the local machine on which the application has been placed. It is not the username that I am providing in

con=DriverManager.getConnection("jdbc dbc BName","username","password");

Can someone please help me figure it out?? Why is it working when I run the tomcat (Apache) and run the application from there, but ones I run it via IIS, it fails. Also, why is it taking the username from the local machine and not the one that I am providing out there?
 
Author
Posts: 531
Mac OS X Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
If i understand you correctly you wanna use Windows authentication
but it is not possible (at least with JDTS which i used).
you just can use MS SQL server with MIXED mode or SQL server authentication mode to access the db from Java.


hope it helps
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


If i understand you correctly you wanna use Windows authentication
but it is not possible (at least with JDTS which i used).


Yes, its not possible to connect to SQl Server via JDBC at all, using anything other than "SQL Server and Windows" authentication, regardless of which Driver you use.
 
Irfan E. Khan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply. So, even if I put it as SQL Server and Windows Authentication, i will still have to use SQL Authentication ONLY?

However, I am still baffled by one thing. Presume the name of the computer is CompName and domain it is in is myDomain. Now, even though I have logged onto to it through the user name XYZ, the error says -

Login failed for user myDomain/CompName

Why is it not stating that login failed for user XYZ. XYZ happens to be the owner of that database too on the SQL Server.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like it is still configured to use Windows Authentication. Are you sure you have changed the authentication settings? Also can you show us how you are logging in?
 
Irfan E. Khan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Paul,

Yes, its still configured to run on Windows Authentication only. I have to wait for the DB Admin to be here to change the settings for it. It should be done in an hour's time and I will post the status / logs for you.

Please bear with me. Thanks!
reply
    Bookmark Topic Watch Topic
  • New Topic