MYOB ODBC Driver Architecture Mismatch

Do you like this?

Summary:
This post shows you how to fix the ODBC connection error The specified DSN contains an architecture mismatch between the Driver and Application, especially for the MYOB ODBC Driver


Content:

MYOB is an accounting software which uses ODBC driver to allow third party applications to connect to its underlying database. However, it supports only the 32 bit connection whereas most operating systems now are running on the 64 bit. This experiment was carried out on a windows 7 64 bit in which java 7 (64 bit) was installed. I used JDBC to connect to ODBC in the following Java example.

import java.sql.*;

public class test {
	public static void main(String[] args) {
		 String jdbcURL = "jdbc:odbc:DSN=MYOB;TYPE=MYOB;Driver={MYOAU1001};"
		 + "UID=Administrator;PWD=;" + "ACCESS_TYPE=READ;"
		 + "SQL_LOGIN_TIMEOUT=40;" + "DRIVER_COMPLETION=DRIVER_PROMPT;";

		Connection conn = null;
		Statement stmt = null;
		ResultSet rs = null;

		System.out.println("Openning");
		
		try {
			Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();

			conn = DriverManager.getConnection(jdbcURL);

			stmt = conn.createStatement();

			System.out.println("Closing");
			conn.close();
		} catch (Exception e) {
			System.out.println("Exception:");
			e.printStackTrace();
		}
	}
}
When you first run this sample, you will face with the following error:
Openning
Exception:
java.sql.SQLException: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
	at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6956)
	at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7113)
	at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3072)
	at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323)
	at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
	at java.sql.DriverManager.getConnection(DriverManager.java:571)
	at java.sql.DriverManager.getConnection(DriverManager.java:233)
The reason you are getting the error is because you are using C:\Program Files\Java\jdk1.7.0_25\jre\bin\javaw.exe which is in the 64 bit mode. If you install the 32 bit version of Java which will be located at C:\Program Files (x86)\Java\jdk1.7.0_21\bin\javaw.exe, it will not give you the error. It sounds complicated but you can use Eclipse IDE which allows you to choose which version of Java you want to use to run your applications. In Eclipse, the option is located at Preferences\Windows\Installed JREs.

 
comments powered by Disqus