0

How to connect to a Microsoft Access-based database in a Windows using JDBC code?

What syntax is to be written for Type-1 and Type-4 types of the drivers?

Class.forName(" ");

Is the above syntax different for everytype of the driver we use? How can we define and identify the type of the driver we use??

If possible then also specify for the oracle also the driver syntax to be loaded..

3
  • 1
    You need to use the JDBC-ODBC bridge See: stackoverflow.com/questions/6339055/… for details Commented Mar 25, 2012 at 20:02
  • 1
    I tried Google, this seemed like a reasonable page, from scanning it: planet-source-code.com/vb/scripts/… Commented Mar 25, 2012 at 20:03
  • con = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ="+ f.getPath() + "//db//JavaAccess.accd","",""); In the above line for making a connection what does DBQ means and thenafter why f.getPath() + "//db//JavaAccess.accd","",""); is written. Thanks.. Commented Mar 26, 2012 at 3:47

4 Answers 4

7

You can use JDBC-ODBC bridge by calling:

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")

Then you can use JDBC database URL in form:

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

or if you configure your database in ODBC manager you can use its alias:

jdbc:odbc:northwind
Sign up to request clarification or add additional context in comments.

2 Comments

Just a note that the JDBC-ODBC Bridge has been removed from the Java 8 JDK and is not supported (ref: here and here). Alternatives include Jackcess and UCanAccess.
sun.jdbc.odbc.JdbcOdbcDriver does not work any more with Java8
7

I recommend a cross-platform Access JDBC driver called UCanAccess. It works great and there are lots of examples on the site (to help the original poster.)

Comments

1

JDBC/ODBC driver is a platform dependent and can be used only in Windows OS. Also, there are some platform independent JDBC drivers, for example: StelsMDB JDBC driver (http://www.csv-jdbc.com/stels_mdb_jdbc.htm)

Comments

-1

To connect Java with MS Access, you need a JDBC driver. I still don't think Microsoft do one do they! http://www.easysoft.com/applications/microsoft-access/jdbc-odbc.html

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.