Search code examples
javams-accessjdbcdriverjdbc-odbc

Java ODBC Ms Access Driver


I am using the following specifications, enter image description here

and I want to learn about Java to Microsoft Access, you can visit the update here

However, there's 2 Files odbcad32 on my system, the first one located on system32 enter image description here

and the second one located on syswow64 enter image description here

I don't know if my Java application is using ODBC on System32 or syswow64,

When i used the following code

public static String DBase =  "jdbc:odbc:datasource_access";

the error shows :

The specified DSN contains an architecture mismatch between the Driver and Application

but when i used the following code

public static String DBase =  "jdbc:odbc:Driver={Microsoft Access Driver(*.mdb)};DBQ=D:\\Java\\u_1401087265\\1401087265db.mdb;";

the error shows

Data source name not found and no default driver specified

It looks like that my Java application is using odbcad32 on System 32 but as we can see, there's no such a Microsoft Access driver 32 bit installed on system, although i have download and install this software

Is there any way to change my Java application to run using odbcad32 on Syswow64 folder ?


Solution

  • I don't know if my Java application is using ODBC on System32 or syswow64

    Have your application display the value returned by

    System.getProperty("sun.arch.data.model")
    

    It will return either "32" or "64" indicating that the application is running in a 32-bit or 64-bit Java Virtual Machine (JVM). You need to be running under a 32-bit JVM to use the DSNs created by "SYSWOW64\odbcad32.exe".

    Is there any way to change my Java application to run using odbcad32 on Syswow64 folder ?

    Install a 32-bit JVM and run your application with it.