-1

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 ?

Community
  • 1
  • 1
Cignitor
  • 681
  • 3
  • 12
  • 35

1 Answers1

0

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.

Gord Thompson
  • 98,607
  • 26
  • 164
  • 342
  • do you mean that my system is already installed `Java` 64bit inside ? so i have to replace them to 32bit ? – Cignitor Nov 20 '15 at 00:00
  • It does sound likely that your machine has a 64-bit version of Java installed. Even so, it is possible to have more than one JVM installed on a machine so you don't necessarily have to *replace* your current Java components, just install a 32-bit JVM and configure your project to use it. – Gord Thompson Nov 20 '15 at 00:05
  • i tried `System.getProperty("sun.arch.data.model")` and it returns `64` , does it mean that my java application is 64bit apps, or Java VM on my computer is 64bit ? however, assuming that i continue to develop my 64bit apps with 64 bit JVM and jdbc odbc driver existed above, is that still possible ? – Cignitor Nov 20 '15 at 13:03
  • It means that your Java application is currently running in a 64-bit Java Virtual Machine (JVM). It does not imply that there is anything about your code that *requires* it to run in a 64-bit environment. So, you should be able to install a 32-bit JVM and use that to run your app. – Gord Thompson Nov 20 '15 at 13:32
  • ... or, you could use the [UCanAccess](http://ucanaccess.sourceforge.net/site.html) JDBC driver and avoid this ODBC nonsense altogether. Details [here](http://stackoverflow.com/q/21955256/2144390). – Gord Thompson Nov 20 '15 at 13:39