File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes ODBC and Microsoft access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "ODBC and Microsoft access" Watch "ODBC and Microsoft access" New topic

ODBC and Microsoft access

Jeff Dube
Ranch Hand

Joined: Jun 14, 2001
Posts: 44
Hi all,
I need to work with a MSACCESS database and i need to connect to this database. Can i connect with JDBC using microsoft access?
I also searched and i often heard about creating a dsn before using odbc driver??? What is dsn?
Is it better to use jdbc or odbc (I am working with windows 2000)?
Daniel Dunleavy
Ranch Hand

Joined: Mar 13, 2001
Posts: 276
Yes you can use MS ACCESS but you will need a driver for it.
Using ODBC is an interum solution. You can use the JDBC-ODBC bridge. Obviously you need to setup the data source(dsn) in ODBC before trying to connect to it. Basically you are giving it a name and what driver to use. In my case I just called it...MyDatabase and it uses a SQL Server driver. Then the connect uses the name MyDatabase to get to ODBC, and ODBC takes it from there.
Eventually you need to get a driver that supports your database because the JDBC-ODBC is not meant to be a production driver (just for development).
Alan Watts

Joined: May 14, 2001
Posts: 28
To add to what Daniel said, in Win98 setting up your DSN (which is like a pointer to a DB file on your system) is relatively straightforward - you need to go to the Control Panel and then open up the ODBC Data Sources icon, and then follow the instructions (fairly simple for Access - perhaps not so simple for say SQLServer). I don't imagine setting up a DSN in Windows 2000 is terribly different.
As Daniel said, using the Sun JDBC:ODBC bridge is a fairly temporary measure - it is a type I JDBC driver, and as I understand it will not work over the internet. So, if you are publishing your Access DB on the web, you will need a commercial driver. I have tried Type III drivers from the following sources (type III drivers are also like the Sun JDBC:ODBC bridge but more sophisticated):
Both of these work nicely with MS Access in my hands, but you can also view a more complete selection of drivers from the Sun site.
Alan Watts
I agree. Here's the link:
subject: ODBC and Microsoft access
It's not a secret anymore!