java - JDBC driver MS Access connection -
i want connect ms access file java gui program,but have problem connection....
i have windows 7 64b, , ms office 2007. when opened odbc driver manager in control panel havent found driver microsoft access (maybe when started odbc started running 64bit odbc, think running 32bit odbc. read , make : "jdbc-odbc connection window 7 64 bit machine.. 1 . right click data source (odbc)..go properties change folloing thing
target [ %systemroot%\syswow64\odbcad32.exe ] start in : [ %systemroot%\system32 ]
press enter , continue admin source: source link " ) when start in conctrol pannel odbc can see driver screenshoot
my program code(i tried 2 ways have same error):
public void connect() { try { class.forname("sun.jdbc.odbc.jdbcodbcdriver"); // string databasefile = "d:java/invertory.mdb"; // string database = // "jdbc:odbc:driver=" // + "{microsoft access driver (*.mdb, *.accdb)};" // + "dbq=" + databasefile;`enter code here` string database ="jdbc:odbc:driver= microsoft access driver (*.mdb, *.accdb);dbq=invertory.mdb"; conex = drivermanager.getconnection(database); } catch (exception x) { x.printstacktrace(); //joptionpane.showmessagedialog(null,e); } }
error
java.sql.sqlexception: [microsoft][odbc driver manager] data source name not found , no default driver specified
use ucanaccess jdbc driver :
class.forname("net.ucanaccess.jdbc.ucanaccessdriver"); connection conn=drivermanager.getconnection("jdbc:ucanaccess://<mdb or accdb file path>",user, password); example: connection conn=drivermanager.getconnection("jdbc:ucanaccess://c:/pippo.mdb");
so example connection conn=drivermanager.getconnection("jdbc:ucanaccess://"+path)
Comments
Post a Comment