Link to home
Start Free TrialLog in
Avatar of senthil kumar
senthil kumar

asked on

Unable to connect to MS-Access database using jdbc-odbc

Hi

I trying to connect to ms-access database using jdbc-odbc on linux, I installed unixodbc and mdbtools and isql runs fine but in connecting to access to db it give me problem.
Unable to connect to database: java.sql.SQLException: [unixODBC][Driver Manager]Data source name not found, and no default driver specified
java.sql.SQLException: [unixODBC][Driver Manager]Data source name not found, and no default driver specified
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)

And here is my sample java code:
   File f = new File("/home/hp/db1.mdb");
String url =  "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" + f.getAbsolutePath()+";";
            Class.forName(driverClassName);
            dbConn = DriverManager.getConnection(url, "","");

Open in new window

and odbcinst.ini
[MDBToolsODBC]
Description             = MDBTools Driver
Driver          = /usr/lib/i386-linux-gnu/odbc/libmdbodbc.so
Setup           = /usr/lib/i386-linux-gnu/odbc/libmdbodbc.so
FileUsage               = 1
UsageCount              = 1

Open in new window

Please help

Regards
sentil
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of senthil kumar
senthil kumar

ASKER

Hi

Thanks for your response, it seems removing "Microsoft Access Driver (*.mdb, *.accdb)" also gives the same exception. Please lemme know how to resolve this problem.

Regards
Sentil
Hi There


The code is absolutely suits our requirements, the last of the link given http://code.google.com/p/mdb-sqlite/ best suits our requirements . Thank you very much and to your team.


Regards
Sentil
You're welcome, glad to help.