I am trying to move an application from 32 to 64 bit JVM. Two small and seldom used features require import/export to a Microsoft Access database. These features are required but their speed and efficiency are of little concern. A problem which has been well described in JDBC-ODBC on 64-bit, unaligned buffers, "Invalid string or buffer length" on Dec 11, 2011 is stopping my progress.
Briefly, the problem is that iterating over a ResultSet can cause an "Invalid string or buffer length" error on a method to get (Int String Double) data from a field. The original poster found that whether this error happens seems to depend on alignment in the stack and cited a Microsoft forum thread about aligning buffers to 64 bit addresses. Another thread in the JDBC forum suggested retrieving strings before doubles.
I found that this allowed about 1000 rows to be processed before the error rather than failing on the first row. The problem is also avoided by stepping through the code in Eclipse. (Perhaps the stack alignment is affected in a beneficial way.)
I am running 64-bit Java(TM) SE Runtime Environment (build 1.6.0_32-b05) on 64-bit Windows 7 Professional SP1. Office 2010 64 bit is installed and updated as is accessdatabaseengine2010sp1-kb2460011-x64-fullfile-en-us (the Microsoft Access engine (ACE) for 64-bit).
I also coded my test program in Perl, using exactly the same MS driver and it works without a problem. This and the earlier thread leads me to believe that there is either some problem in Java JDBC or this MS buffer alignment requirement is not consistent with ODBC. I have tested with the latest 1.6 and 1.7 Java releases and the latest Microsoft driver ("Microsoft Access Driver (*.mdb, *.accdb)" Version 14.00.6015.1000).
I would greatly appreciate hearing from anyone who has been able to use JDBC with the Microsoft Access 64 bit driver or has spent significant effort and given up. Thanks.
Edited by: user5664922 on Mar 4, 2013 8:00 AM
What a wall of text. Ever thought about adding some spacing to make it easier on the reader? Help people help you and all that... I can only say what I'd do: not run the 64 bits runtime in this case. A 32 bits runtime works just fine in a 64 bits environment, unless you need huge amounts of memory (which is not likely when you have to use limited tools like Access).
I have another bit of news on that front btw: the ODBC-JDBC bridge is going to be dropped from Java 8.
So support for plorking around with Access in this manner is going to be dropped from core Java even. Its too big a hint to ignore.
Thank you for enduring my massive paragraph (I have now edited) and the news of ODBC-JDBC bridge being removed a V8. That is helpful to know. The product I am working on will be replaced in a few years, so any info on the original question will still be appreciated from anyone who has had to deal with this.