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......
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.
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.