wood burning stoves*
The moose likes JDBC and the fly likes java.sql.SQLException[ODBC Driver Manager]Data source name not found and no default driver specified Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.sql.SQLException[ODBC Driver Manager]Data source name not found and no default driver specified" Watch "java.sql.SQLException[ODBC Driver Manager]Data source name not found and no default driver specified" New topic
Author

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

Jahnavi Janu
Greenhorn

Joined: Apr 10, 2009
Posts: 5
Hi All,

I am trying to connect to the MS Access database.But exception is coming like

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

But i created DSN Name and selected exiesting *.mdb database.


What might be the reason?Please help me to find out the error.

Thank You,

Jahnavi
Arvind Subramanian
Ranch Hand

Joined: Jul 25, 2008
Posts: 84
problem must be in the driver and classpath. i dint used mdb as my backend, but for my db if i get this error means it only because of driver not present in the CLASSPATH provided...


"Many of lifes failure are people who did not realize how close they were to success when they gave up."
-Thomas Edison
~ar~stutzen~
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39436
    
  28
Welcome to JavaRanch

Don't know.

But it would be helpful if you provided more details, including your classpath used, the location of the driver class, and the code you are using to open the connection.
Jahnavi Janu
Greenhorn

Joined: Apr 10, 2009
Posts: 5
Hi Aravind & Ritchie,

What i did all is opening 'Control Panel +Administrative tools+Data Sources(ODBC)+System DSN+ Add + Microsoft Access Driver(*mdb)+Finish+DSN Name'


Then i used this DSN Name in DriverManager.getConnection(DSNName).Then when i run the project the above exception is generated.Is there anything to do with the Classpath in configuring the DSN?

Thank You.

Sujay Nadkarni
Ranch Hand

Joined: Jul 03, 2008
Posts: 34
please paste your code.. it will give us a little more idea!!
Jahnavi Janu
Greenhorn

Joined: Apr 10, 2009
Posts: 5
Hi Sujay Nadkarni,

As you said i am pasting my code here.

protected Connection getConnection () throws Exception{
try {

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbcdbc:globalcnts");


conn.setAutoCommit (true);

}
catch (SQLException sqle) {
context.log (" Error getting database connection", sqle);
}
return conn;
}

protected void freeConnection (Connection conn) {
try {
if (conn != null) {
conn.commit ();
conn.close ();
}
}
catch (Exception sqle) {
context.log ("Error freeing database connection", sqle);
}
}

I gave my DSN Name as globalcnts..Please redtify my doubt..

Thank You..
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

That error ALWAYS means your DSN name is incorrect or can't be accessed for some reason (permission). The ODBC part says that the bridge is working.

But that DSN is 100% wrong or cannot be seen by the user account that the server is running as. Make sure you have a system DSN and not a user one.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Jahnavi Janu
Greenhorn

Joined: Apr 10, 2009
Posts: 5
Hi Sagar,

I configured DSN like 'Control Panel -->Administrative tools-->Data Sources(ODBC)-->System DSN-->Add -->Microsoft Access Driver(*mdb)-->Finish-->DSN Name-->select-->mydatabase.mdb-->OK' . Is there anything wrong in configuring DSN.And I configured in UserDSn once and by googling i came to know that we have to use system DSN so..I kept it in System DSN.Then also its showing same error like above..Plase let me know where i have done the mistake?


Thank You.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

You missed my first point regarding DSN name, What you created is :
mydatabase.mdb-->OK'

And what you're accessing is:


globalcnts != mydatabase

Also Google the same error/exception, you will get plenty of hits.
Jahnavi Janu
Greenhorn

Joined: Apr 10, 2009
Posts: 5
Hi Sagar,

I mean to say

'Control Panel -->Administrative tools-->Data Sources(ODBC)-->System DSN-->Add -->Microsoft Access Driver(*mdb)-->Finish-->globalcnts(DSN Name)-->select-->mydatabase.mdb-->OK'


MY DSN name is globalcnts and am selecting database from where it is existing.My database name is mydatabase.mdb it exists in D:\Tomcat 5.0\webapps\Visu\mydatabase.mdb.

I am not trying to create new one.I am trying to connect with already existing database.Is there anything wrong in this Sagar..
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

oops sorry, I thought that was a DSN name, Look I never used Java with Access. But as I told earlier, If you searched on net regarding the Exception, you get some answers, meanwhile some suggestion, Try connection with empty user name and password. Like,

pallavi kamathe
Greenhorn

Joined: Mar 02, 2009
Posts: 3
Hello Janavi,
I think you have made problem in getting connection...
Connection con=DriverManager.getConnection("jdbc:odbc:DSN","username","Password");

Thanks..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.sql.SQLException[ODBC Driver Manager]Data source name not found and no default driver specified