That mouth full of a title sums up quite nicely what I’ve been trying to get working today: a JDBC-ODBC bridge connection to a 32bit Access database running on a 64bit version of Windows 7. Phew, I’m tired just thinking about it.
Normally I’d rather gouge one of my own eyes out with a spade than attempt something like this but needs must as I have to access an Access database being used by one of our legacy applications which has still got some life left in it. To complicate an otherwise already complicated enough situation I also don’t have any full version of Access on my machine so I’m replying on the free Office 2010 redistributable 32bit version (I can’t install the 64bit version because I have 32bit office minus Access installed). I’m told worse things happen at sea…
The first step is to get either Office and Access or the redistributable installed on your machine. If you are running Windows 7 64bit you then have to dig around in you Windows install finder for this:
For some unimaginably silly reason the regular ODBC setup application can’t create the DSNs desired (I suspect because it’s 64bit and we are trying to create 32bit DSNs). Make a DSN called Test or some such and then create a little test project in your favourite IDE. Now, change the projects Java version from a 64bit install to a 32bit install – you have got both installed right…
The reason you have to make this last change is to avoid this error:
Exception: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
Presumably this is because in a 64bit version of Java the bridge driver is compiled as 64bit but it’s trying to connect to a 32bit DSN. The little snippet of code below will confirm that you have a good connection to the database by providing a little metadata about it.