If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > JAVA > Cannot connect to Access 2007

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-01-09, 08:15
slen slen is offline
Registered User
 
Join Date: Jan 2009
Posts: 1
Cannot connect to Access 2007

I am wandering how I can connect to Access 2007 with Java.

I got an exception error for connecting to Access 2007 (.accdb) . However, I can connect to the Access file with the .mdb file. I am using window vista. I would like to know is there anything I need to configure to be able to connect to the Access (.accdb).

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

How do I specify a driver?


had anyone experienced this problem and actually found a solution?

Thank You
Reply With Quote
  #2 (permalink)  
Old 01-28-09, 00:24
hkp819 hkp819 is offline
Registered User
 
Join Date: Dec 2008
Posts: 59
Hope that is useful for you....
//class definition
private static DatabaseManagement instance = null;
private String DB_URL="jdbc Driver={Microsoft Access Driver (*.mdb ,*.accdb)};DBQ=";
private final String DB_DRIVER="sun.jdbc.odbc.JdbcOdbcDriver";
private String filename="Jan.accdb";
private Connection con=null;
//constructor
Class.forName(DB_DRIVER).newInstance();
DB_URL+=filename.trim()+";DriverID=22;READONLY=tru e}";
con = DriverManager.getConnection( DB_URL ,"","");
it create the object in the main with new operator.
__________________
New York Web design
Website design

Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On