This discussion is archived
4 Replies Latest reply: Oct 29, 2012 2:25 AM by 970609 RSS

JDBC OBDC Windows 7 connection problems

970609 Newbie
Currently Being Moderated
This is giving me a headache! My machine has recently been upgrared to Windows 7 and my java app (which read MS Access 2007) no longer works.

I understand this usually down to 64 bit vs 32 bit OS issues. So I have:

1) Installed 32 bit version of eclipse and compiled with the VM arg -D32 (just to make sure). My connection string is as follows:

private String strDSNless = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=c:\\mydb\\mydb.accdb;";
Connection con = DriverManager.getConnection(strDSNless , "","");

This gives me:

"java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
     
2) Ok, so I tried using a DSN connection using the 32bit ODBC using %windir%\SysWOW64\odbcad32.exe.

private String strDSN = "jdbc:odbc:mydb";
Connection con = DriverManager.getConnection(strDSN);

This gives me:

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

Help!
  • 1. Re: JDBC OBDC Windows 7 connection problems
    rp0428 Guru
    Currently Being Moderated
    Welcome to the forum!
    >
    private String strDSNless = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=c:\\mydb
    mydb.accdb;";
    Connection con = DriverManager.getConnection(strDSNless , "","");

    This gives me:

    "java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified"
    >
    Do you really have a file named 'mydbmydb.accdb' at that location? Or are you missing a directory separator?
  • 2. Re: JDBC OBDC Windows 7 connection problems
    970609 Newbie
    Currently Being Moderated
    I changed the filenames when I posted, however, the filename is correct! as I mentioned this worked peferct on XP prior to my machine being uplifted to Windows 7.
    Cheers
    Rob
  • 3. Re: JDBC OBDC Windows 7 connection problems
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    967606 wrote:
    1) Installed 32 bit version of eclipse and compiled with the VM arg -D32 (just to make sure).
    Maybe that is misstated but that option is a run time option not a compiler option.
    This gives me:

    [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
    You can add code that tells you what VM you are running which will tell you whether 32 or 64 bit is running. You should check that value and exit, with a message, if it is not correct. You would do that before attempting to create a connection.
  • 4. Re: JDBC OBDC Windows 7 connection problems
    970609 Newbie
    Currently Being Moderated
    Yes, thanks a lot! Its now working.

    System.out.println(System.getProperty("sun.arch.data.model"));

    Proved I was still using the 64 bit JRE.

    So I went to Window -> Preferences -> Installed JRE

    and searched and found the 32bit JRE in c:\Program Files (x86)\Java.

    :)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points