ms access - java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver Exception occurring. Why? -


i have created ms access database , assigned dsn it. want access through java application.

this doing:

public class accessdbconnection {      public static void main(string[] args) {         system.out.println("**access db connection**");          try {             class.forname("sun.jdbc.odbc.jdbcodbcdriver"); // ms access ... ms access driver loading              string     conurl    = "jdbc:odbc:sampledns";             connection con       = drivermanager.getconnection(conurl);             statement  statement = con.createstatement();             string     qry       = "select * table1";             resultset  rs        = statement.executequery(qry);              while(rs.next()) {                 string id    = rs.getstring("id") ;                 string fname = rs.getstring("first_name");                 string lname = rs.getstring("last_name");                 system.out.println(id + fname + lname);             }         } catch (classnotfoundexception ex) {             system.out.println("classforname exception!!");             logger.getlogger(accessdbconnection.class.getname()).log(level.severe, null, ex);         } catch (sqlexception ex) {             system.out.println("drivermanager exception!!");             logger.getlogger(accessdbconnection.class.getname()).log(level.severe, null, ex);         }     } } 

i getting exception @ first line of try block. class.forname("..");. why having exception?

for java 7 can omit class.forname() statement not required.

for java 8 cannot use jdbc-odbc bridge because has been removed. need use ucanaccess instead. more information, see

manipulating access database java without odbc


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -