The Java connection to the access database fails?

advertisements

Iam using windows 8.1 (64 bit) with microsoft office 32bit version. Iam trying to connect to an access file to retrieve username and password but the connection to the access database cannot be made, I have searched alot on the internet but can't seem to find a solution for this problem. I downloaded office 64bit with Microsoft Access Database Engine 2010 Redistributable but I still get the same error. What should I do to overcome this issue?

Java method:

dbcon()
{
try{     

   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
   con=DriverManager.getConnection("jdbc:odbc:db5");

  }catch(Exception e){
   System.out.println(e);
 }
 }

Error:

java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
java.lang.NullPointerException
null


This may be the fact that your ODBC driver is 32 bit, which can not be recognized by the 64 bit Java. Either create a 64 bit ODBC driver or run Java in 32 bit mode (-D32 switch).