Solved

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

Posted on 2014-10-15
4
944 Views
Last Modified: 2014-10-16
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
0
Comment
Question by:senthil kumar
  • 2
  • 2
4 Comments
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
Comment Utility
AS far as I know, the driver "Microsoft Access Driver (*.mdb, *.accdb)" only runs on Windows, not Linux.  I haven't found any driver that does work although I got part of this code to work:  https://gist.github.com/amirkdv/9672857
0
 

Author Comment

by:senthil kumar
Comment Utility
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
0
 

Author Closing Comment

by:senthil kumar
Comment Utility
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
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
You're welcome, glad to help.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now