This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting a problem while using database connectivity

 
sushil parti
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,
i am a newbie to java... i have just joined an institute for that and the tutor is teaching java on netbeans
but i liked eclipse more. So i am doing on that.
A few days ago my tutor taught us database connectivity without using DSN so that it could be deployed easily which i have implemented in the code below
But i am getting an error :

java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

I have checked the code again and again but can't find the error in it. Further my teacher is not able to find the error and is blaming the eclipse for that and is saying it is due to some internal error of laptop. I am not sure what to do ..

please help me a soon as possible..here is the code.. :



Please reply if any one here knows the solution......
Thank you
 
Jan Cumps
Bartender
Posts: 2602
13
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, sushil.

Please read these instructions on how to use code tags to make your post more readable.
We have a general tutorial on how to ask questions.

Regards, Jan
 
Ireneusz Kordal
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

try to change this line:

and use an absolute pathname instead of relative, for example:


 
sushil parti
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ireneusz
Thanks for replying....

i changed that relative address to have an absolute one .
But still it is not working properly..

Actually There is no compilation error. But when i click on login button after putting the username and password
the error comes.

any guesses what should i do
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code you have is a little odd. This line:

is a funny way of registering a driver, and kind of works against one of the principals of JDBC: that you code should be portable.

The error you see usually occurs when you are using a DSN rather than a trying a DSN-less connection. The error means that ODBC can't find a data source name. Given you have been working with DSN version previously, I would check the code you are actually running. Are there any old classes kicking about?

I'm not sure what the "DriverID=22;READONLY=false" in your connection string means - I've only ever seen it used (mis)using JDBC to connect to Excel. Try removing
it from the string.

 
sushil parti
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
thanks everybody for your help
well somehow my code is running again after i replaced it with following code
but i still can't get how. Does any body know??
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34974
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't easily tell what is different between the new and old code because the old code is long and unformatted.

I do want to point out that your application is vulnerable to SQL Injection where someone can enter SQL in the user/password fields and login even without a valid id. You really should be using a PreparedStatement.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic