2

I am trying to connect my java program with a MS ACCESS database. I looked a lot on the internet, but I don't find my problem. I wrote the code:

private String dburl="jdbc:odbc:DRIVER={Microsoft Access Driver(*.mdb)};DBQ=Database1.mdb";
...
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
c=DriverManager.getConnection(dburl);

And I get the folowing error:

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

I make a DNS from my database. And I tried a lot, but I keep having the error. I also try with the exact location where the database is, I tried to put the created DNS in the folder of my java program,...

Can someone help me please?

0

3 Answers 3

1

If somehow possible, don't use a JdbcOdbc driver, but a pure JDBC-Driver for your database

OR

Try this:-

DriverManager.registerDriver((Driver) 
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance());
c= DriverManager.getConnection(dburl,"","");

This will ensure that the "sun.jdbc.odbc.JdbcOdbcDriver" class is loaded and connected to the DriverManager.

Sign up to request clarification or add additional context in comments.

1 Comment

I get the same error with your code. How do I do to use a pure JDBC-driver ?
1

The error message "Data source name no t found and no default driver specified" is all you need. It can't locate the database Database1.mdb. You might want to try specifying the absolute path to the driver.

5 Comments

I already tried with the absolute path, but it doesn't word neither. I wrote dburl="jdbc:odbc:DRIVER={Microsoft Access Driver(*.mdb)};DBQ=C:/Users/Jurgen Decuyper/Documents/Database1.mdb";
Do you actually have the Access Driver installed?
You are not using a system DSN in your connection string.
And how do I use a system DSN in my connection string?
Use jdbc:odbc:<name-of-your-dsn>
0

How do I do to use a pure JDBC-driver ?

HXTT Access (a commercial pure Java type 4 driver) is at http://www.hxtt.com/access.html .

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.