Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

SQL Server DSN - JdbcOdbcDriver

 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys! I'm hoping you can steer me in the right direction on this. Here is a snip of the code I'm using to connect to a MS SQL database.


This works just fine. But I've set the UserID and Password in my class. What I want to do is let the DSN I've setup on my PC to use the userID and password that is established in it.

So I modify my code like this.


Or



Compile and run the application and I get a SQl Exception - Login failed for user '<null>'

Am I missing something here or is the JdbcOdbcDriver not up to this?


Thanks for any help you can offer.

Steve
 
Stephen Boston
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, all my research hasn't turned up anything to help, so I've altered my class to accept DSN, UserID and Password as arguments. I've set up a login form to call the method in the class and bounce a simple query against the database and catch and handle any exception that may come back that deals with the user id or password.

Does anyone have a better way to approach this?

Steve
 
author & internet detective
Posts: 41085
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Steve,
I haven't used SQL Server so I'm not sure. In general, it is good to put the username/password in a property file. That way it isn't hardcoded into the app. Not as good as what you are trying to do, but better than nothing.
 
Stephen Boston
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jeanne,

Thank you for your reply. I hadn't thought of a property file (maybe that is because I haven't discovered those yet. )

I will investigate that and see if that will work better than the login form method. If it don't work for this application, it will come in handy for another application I'm working up for dog agility club (Contact Zonies in Phoenix Arizona http:///www.contactzoines.org in case someone is wondering. )



Steve
[ August 20, 2005: Message edited by: Stephen Boston ]
 
Let's go to the waterfront with this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic