Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help Connecting To An Access 2007 DB

843859Jan 22 2008 — edited Nov 20 2014
Ok,

I'm having trouble getting my java program to connect to the new .accdb MS Access 2007 database file. I downloaded the new data connectivity tool for Office 2007 and I'm still getting [Microsoft][ODBC Microsoft Access Driver] Cannot open database '(unknown)'. It may not be a database that your application recognizes, or the file may be corrupt.

Here's the code I'm using to connect
      String filename = dbFile.getPath();
      String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=";
      database+= filename.trim() + ";DriverID=22;READONLY=false}"; // add on to the end 
      // now we can get the connection from the DriverManager
      Connection con = DriverManager.getConnection(database); 
      Statement s = con.createStatement();
Can anyone tell me what I need to do to get this piece of code to connect to a 2007 Access database file? By the way, this works perfect with a 2003 Access database file (.mdb). Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 19 2008
Added on Jan 22 2008
6 comments
448 views