I am able to create a connection with 64 bit office but I want to connect with 32 bit office.
Still after reading so many articles regarding this, I still am unable to create a DB connection with MS Access using Java
I have:
- 64 Bit JDK
- 64 Bit Windows
- 32 Bit Ms Office
Now I have created a DSN using odbcad32 in SysWow folder because I have 32 bit MS Access.
Here is my Java code:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.accdb,*.mdb)};DBQ=C:/Users/Rahul/Documents/test.accdb;";
//Connection conn = DriverManager.getConnection(database, "", "");
Connection conn = DriverManager.getConnection("jdbc:odbc:hello");
Statement s = conn.createStatement();
ResultSet rs = s.executeQuery("Select * from user");
while((rs!=null) && (rs.next()))
{
System.out.println(rs.getString("fullname"));
}
Still getting this error:
java.sql.SQLException: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
and if I change the Connection code above which is commented. I get this error :-
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
I have installed AccessDatabaseEngine 32 bit, but still I am unable to create a connection.
If I try to create DSN using odbcad in System32 folder (for64 bit office), I get this error:
the setup routines for the microsoft access dbase driver odbc driver could not be found
What am I missing here as I have tried everything.