java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] -
i using program connecting ms access 2007 , getting exception please me out.the exception is, have checked many tutorials not getting best solution.
java.sql.sqlexception: [microsoft][odbc microsoft access driver] not find file '(unknown)'.
at sun.jdbc.odbc.jdbcodbc.createsqlexception(jdbcodbc.java:6956) @ sun.jdbc.odbc.jdbcodbc.standarderror(jdbcodbc.java:7113) @ sun.jdbc.odbc.jdbcodbc.sqldriverconnect(jdbcodbc.java:3072) @ sun.jdbc.odbc.jdbcodbcconnection.initialize(jdbcodbcconnection.java:323) @ sun.jdbc.odbc.jdbcodbcdriver.connect(jdbcodbcdriver.java:174) @ java.sql.drivermanager.getconnection(drivermanager.java:579) @ java.sql.drivermanager.getconnection(drivermanager.java:221) @ multithreading.dbaccess.main(dbaccess.java:14) import java.sql.*; public class dbaccess { public static void main(string[] args) { try { class.forname("sun.jdbc.odbc.jdbcodbcdriver"); string database = "jdbc:odbc:driver={microsoft access driver (*.mdb)};dbq=payroll.mdb;"; connection conn = drivermanager.getconnection(database, "", ""); statement s = conn.createstatement(); // create table string tablename = "mytable" + string.valueof((int)(math.random() * 1000.0)); string createtable = "create table " + tablename + " (id integer, name text(32))"; s.execute(createtable); // enter value table for(int i=0; i<25; i++) { string addrow = "insert " + tablename + " values ( " + string.valueof((int) (math.random() * 32767)) + ", 'text value " + string.valueof(math.random()) + "')"; s.execute(addrow); } // fetch table string seltable = "select * " + tablename; s.execute(seltable); resultset rs = s.getresultset(); while((rs!=null) && (rs.next())) { system.out.println(rs.getstring(1) + " : " + rs.getstring(2)); } // drop table string droptable = "drop table " + tablename; s.execute(droptable); // close , cleanup s.close(); conn.close(); } catch(exception ex) { ex.printstacktrace(); } } }`
you can refer this. help
also, goto control panel-> administrative tools-> data sources-> add-> microsoft access drivers(*mdb,*accdb)-> ok-> ok-> ok. might work odbc connection.
also, have provide correct path payroll.mdb in
dbq=payroll.mdb
Comments
Post a Comment