Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Kv Payal
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to execute a jdbc program to read data from MS Excel(I have Microsoft Excel Starter 2010) on Windows 7, 64bit operating system.

I created a system DSN(and also tried with UserDSN) the following program and it is throwing the exception :

Exception: [Microsoft][ODBC Driver Manager] : The specified DSN contains an architecture mismatch between the Driver and Application

Program
//import java.io.*;
import java.sql.*;
public class ExcelReadTest{
public static void main(String[] args){
// Connection connection = null;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection( "jdbcdbc:test2" );
Statement st = con.createStatement();
ResultSet rs = st.executeQuery( "Select * from [Sheet1$]" );

ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();


while (rs.next()) {
for (int i = 1; i <= numberOfColumns; i++) {
if (i > 1) System.out.print(", ");
String columnValue = rs.getString(i);
System.out.print(columnValue);
}
System.out.println("");
}

st.close();
con.close();
} catch(Exception ex) {
System.err.print("Exception: ");
System.err.println(ex.getMessage());
}
}
}

Note :I used c:\windows\sysWOW64\odbcad32.exe to create a data source that connects to a 32-bit driver under 64-bit platform,. I also tried c:\windows\system32\odbcad32.exe to connect a 64-bit driver but there was no driver for MS Excel. Only driver for SQL Server was available

Can somebody please help me to run the jdbc program in windows 7 and let me know what drivers do I need to use and how?

Thanks in advance.
 
Jan Cumps
Bartender
Posts: 2588
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you check this thread:
http://www.coderanch.com/t/533801/JDBC/java/error-connect-java-ms-access

Regards, Jan
 
Brad Thiru
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm also facing the same issue when my system recently got upgraded to Windows 7 64 bit. I've tried setting up of DSN via C:\Windows\SysWOW64\odbcad32.exe. But i'm getting the same error msg. I got bit struck. If anyone has any solution, Please do share the same.

Thanks,
Brad
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic