ms access - Why am I getting "Data source name not found and no default driver specified"? -
from java, want connect .accdb file in server (dsn less) , keep getting error. googled few hours , not find anything. please help!
string surl = "jdbc:odbc:driver={microsoft access driver (*.mdb, *.accdb)};dbq=dbq=c:/test/thedb.accdb;readonly=true;"; try { class.forname("sun.jdbc.odbc.jdbcodbcdriver"); log.debug("url: "+surl); // create connection database using connection string dbcon = drivermanager.getconnection(surl); } catch(sqlexception e) { //retry try{dbcon = drivermanager.getconnection(surl);} catch(sqlexception ex){ // now, real failing. throw exception log.error("fail second time",ex); throw new sqlexception(e.getmessage()); } } catch (classnotfoundexception e) { log.error(e.getmessage()); throw new sqlexception(e.getmessage()); } return dbcon;
here's exception get:
java.sql.sqlexception: [microsoft][odbc driver manager] data source name not found , no default driver specified @ sun.jdbc.odbc.jdbcodbc.createsqlexception(unknown source) [na:1.7.0_10] @ sun.jdbc.odbc.jdbcodbc.standarderror(unknown source) [na:1.7.0_10] @ sun.jdbc.odbc.jdbcodbc.sqldriverconnect(unknown source) [na:1.7.0_10] @ sun.jdbc.odbc.jdbcodbcconnection.initialize(unknown source) [na:1.7.0_10] @ sun.jdbc.odbc.jdbcodbcdriver.connect(unknown source) [na:1.7.0_10] @ java.sql.drivermanager.getconnection(unknown source) [na:1.7.0_10] @ java.sql.drivermanager.getcon...
dbq=dbq=c: ...
cause problems. 1 dbq=
sufficient.
Comments
Post a Comment