Java – Accessing Access over JDBC (using ODBC?)

javajdbcms-accessodbc

I'm looking for a way to open an Access MDB file inside a Java App (using JDBC).

A quick Google Search suggests that I need the JDBC-ODBC Bridge for this…

Does this mean that I need to configure every system I want to run my app on to provide a ODBC DSN for the MDB I want to open?

And one more question (since I've never used ODBC before): will the communication happen over some sort of a socket (in a client/server-style), or through method/function calls (like with an embeded Derby db)?

Best Answer

1) You won't need to configure every system with a SYSTEM or USER ODBC DSN to access the MDB you want. You can still provide all the information you need in your JDBC URL:

jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=c:/yourdb.mdb

But keep in mind that the system will need to have the driver you are using installed.

2) The communication will happen the way your ODBC driver communicates. If it opens a socket to the server (the way an Oracle ODBC connection takes place) it will open a socket. If it uses library function calls, it will communicate through library function calls.

JDBC to ODBC communication uses JNI to communicate.