Results 1 to 7 of 7
Thread: JDBC ODBC SQLException
- 05-28-2011, 04:34 AM #1
Member
- Join Date
- May 2011
- Posts
- 64
- Rep Power
- 0
JDBC ODBC SQLException
Hello I am trying to connect to a data source with the ODBC Data Source Administrator but I am getting an error when I run.
The error that I am getting is:
The code is:Java Code:SQL Error: java.sql.SQLException: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application 0 IM014
I have used the odbcad.32 in this location: c:\windows\sysWOW64\odbcad32.exe as advised by this website: Managing Data Sources but I still get the error.Java Code:import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class CoalReporter { public static void main(String[] args){ String data = "jdbc:odbc:WorldEnergy"; try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn = DriverManager.getConnection( data,"",""); Statement st = conn.createStatement(); ResultSet rec = st.executeQuery( "SELECT * "+ "FROM Coal "+ "WHERE "+ "(Country='"+args[0]+"') "+ "ORDER BY Year"); System.out.println("FIPS\tCOUNTRY\t\tYEAR\t"+ "ANTHRACITE PRODUCTION"); while(rec.next()){ System.out.println(rec.getString(1)+"\t" +rec.getString(2)+"\t" +rec.getString(3)+"\t" +rec.getString(4)); } st.close(); }catch(SQLException s){ System.out.println("SQL Error: "+s.toString()+" " +s.getErrorCode()+" "+s.getSQLState()); }catch(Exception e){ System.out.println("Error: "+e.toString() +e.getMessage()); } } }
- 05-28-2011, 05:33 AM #2
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
what database are you trying to connect?
- 05-28-2011, 05:35 AM #3
Member
- Join Date
- May 2011
- Posts
- 64
- Rep Power
- 0
I'm trying to connect to a MS access DB
- 05-28-2011, 05:59 AM #4
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
Check step 1 to 4. Have you done this steps?
Accessing Ms Access Using Java
You could also try to change your string data to something like this,
I am not familiar using MSAccess in java so this might NOT be the CORRECT WAY to connect it.Java Code:String databasePath = "D:\\myDatabase.mdb"; String data = "jdbc:Odbc:Driver={Microsoft Access Driver (*.mdb)};" + "DBQ=" + databasePath;
- 05-28-2011, 06:10 AM #5
Member
- Join Date
- May 2011
- Posts
- 64
- Rep Power
- 0
I checked that I had followed those steps and I have, I also tried the code you gave me, but I am still getting the same error. I am using 64 bit machine if that is any use to you.
- 05-29-2011, 08:00 AM #6
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Uhm, you have a "64 bit system", but do you have a "64 bit Office" or is your office suite 32 bit. According to the error (and the page you provided) it looks as though your office system is 32 bit and therefore you are using the 64 bit odbcad32.exe to configure a 32 bit driver and there fore are getting an error when using that configuration.
- 05-30-2011, 08:07 AM #7
Member
- Join Date
- May 2011
- Posts
- 64
- Rep Power
- 0
Similar Threads
-
jdbc-odbc cannot connect
By ArneBassez in forum JDBCReplies: 4Last Post: 12-08-2010, 05:26 AM -
Can any one tel...who has developped JDBC-ODBC driver...?
By Hello1976 in forum New To JavaReplies: 1Last Post: 07-23-2010, 09:23 AM -
java.sql.SQLException: [Oracle][ODBC][Ora]ORA-00904: invalid column name
By OMFGITSROHIT in forum JDBCReplies: 1Last Post: 04-05-2010, 01:32 AM -
Help me this error in JDBC-ODBC connection
By lordelf in forum Java ServletReplies: 3Last Post: 04-04-2009, 08:37 AM -
Using JDBC-ODBC bridge
By Java Tip in forum Java TipReplies: 0Last Post: 02-06-2008, 09:21 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks