This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Jahnavi Janu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Campbell Ritchie
Sheriff
Posts: 48645
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please paste your code.. it will give us a little more idea!!
 
Jahnavi Janu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jahnavi Janu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Janavi,
I think you have made problem in getting connection...
Connection con=DriverManager.getConnection("jdbc:odbc:DSN","username","Password");

Thanks..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic