2

I am using this tutorial to create a database connection from a java application to a Microsoft Access 2010 database. The tutorial creates a system dsn in windows, and then connects to that system dsn using the following line of java code:

Connection conn = DriverManager.getConnection("jdbc:odbc:DSN_NAME");   

The problem is that, when I click the link to add a new system dsn at:

Control Panel --> System and Security --> Administrative Tools --> Data Sources (ODBC) --> (System DSN Tab) --> (Add.. button)  

It does not give me an option to choose Microsoft Access as the database type. Instead, the options given are shown in the following printscreen:

I am wondering if this is a driver issue, where I need to download something. Or if it is a configuration issue. I am using Windows 7. Can anyone show me how to fix this so that I can create the System dsn required to complete this tutorial? Or at least show me another easy way to connect to a Microsoft Access database from java?

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
CodeMed
  • 9,527
  • 70
  • 212
  • 364
  • Try having a look at [this example](http://stackoverflow.com/questions/6339055/how-to-connect-java-to-ms-access-2010) – MadProgrammer Sep 11 '13 at 21:19
  • And [this example](http://www.selikoff.net/2011/07/26/connecting-to-ms-access-file-via-jdbc-in-64-bit-java/) which discuses issues between 32 & 64 bit environments – MadProgrammer Sep 11 '13 at 21:22

1 Answers1

4

64-bit Windows machines have two separate "ODBC Data Source Administrator" control panels: one that creates 64-bit DSNs for 64-bit applications, and a separate one that creates 32-bit DSNs for 32-bit applications. On a 64-bit Windows machine,

Control Panel > Administrative Tools > Data Sources (ODBC)

will open the 64-bit ODBC Data Source Administrator. To open the 32-bit counterpart you need to run

C:\Windows\SysWOW64\odbcad32.exe

You don't see an Access database driver because you are running a 64-bit version of Windows and there is no 64-bit Access driver included with Windows. Windows does ship with a 32-bit Jet driver (.mdb files only).

So, you will need to do one of the following:

  • If you are running a 32-bit version of Java and you want to connect to an .mdb file then you need to launch the 32-bit ODBC Data Source Administrator as described above.

  • If you are running a 32-bit version of Java and you want to be able to connect to both .accdb and .mdb files then you need to download and install the 32-bit version of the Access Database Engine from here and then launch the 32-bit ODBC Data Source Administrator as described above.

  • If you are running a 64-bit version of Java then you need to download and install the 64-bit version of the Access Database Engine from here.

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
  • 1
    +1 for such a thorough answer. I did not need to use the Access Database engine because I have Access installed on the machine. I did find the 32 bit ODBC Data Source Administrator, but the solution came more from configuring eclipse to run a 32 bit jdk to connect to the 32 bit DNS. Cheers! – CodeMed Sep 12 '13 at 00:28
  • I deleted some redundant posts so the site is easier to use. Thank you for looking into the new issue. I was able to get my one eclipse project to use 32 bit jdk by following the instructions in this other posting: http://stackoverflow.com/questions/9302687/how-can-i-tell-eclipse-to-compile-and-build-a-project-with-a-different-jre-versi – CodeMed Oct 25 '13 at 02:49