Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Getting a problem while using database connectivity

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 2662
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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??
 
author & internet detective
Posts: 41967
911
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
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic