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( "jdbc:odbc: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.