java - How to resolve [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified -
i tried make connection access encountered following problem after compiling java file
[microsoft][odbc driver manager] data source name not found , no default driver specified
my code :
import java.sql.*; public class abc { public static void main(string args[]) { try { class.forname("sun.jdbc.odbc.jdbcodbcdriver"); string fn="c:/ctb/new"; string database = "jdbc:odbc:driver={microsoft access driver (*.mdb,*.accdb)};dbq="+fn+".accdb;"; connection conn = drivermanager.getconnection(database); system.out.println(conn); } catch(exception e) { e.printstacktrace(); system.out.println("error!"); } } }
when copy , paste code eclipse error message mention. because driver name malformed. instead of...
string database = "jdbc:odbc:driver={microsoft access driver (*.mdb,*.accdb)};dbq="+fn+".accdb;";
...you need use...
string database = "jdbc:odbc:driver={microsoft access driver (*.mdb, *.accdb)};dbq="+fn+".accdb;";
note single spaces in ... driver (*.mdb, *.accdb)...
Comments
Post a Comment