java - can't make updatable resultset with ucanaccess -
i've tried of examples found here , web, can't open ms access database(2002 or 2013) , updatable result set using ucanaccess. same code using jdbc:odbc driver/connection/works. i've written short test code check concur_updatable check this, must missing something. i'm using jdk 1.7 on win7 machine. have machine same results. works:
/* class jdbc, testing jdbc:odbc concur_updatable. */ import java.sql.*; public class jdbc { private static string dbfqn; public static void main(string[] args) { try { dbfqn = ("c:\\phil\\programming\\kpjl2002.mdb"); string database = "jdbc:odbc:driver={microsoft access driver (*.mdb)};dbq=" + dbfqn; system.out.println("loading database: " + database); connection conn = drivermanager.getconnection(database, "", ""); statement s = conn.createstatement(resultset.type_scroll_sensitive, resultset.concur_updatable); // fetch records table string seltable = "select * " + "tbllibrary" + " order artist, cat, cart"; s.execute(seltable); resultset rs = s.getresultset(); int concurrency = rs.getconcurrency(); if(concurrency == resultset.concur_updatable) { system.out.println("rs updatable"); } else { system.out.println("rs not updatable"); } s.close(); conn.close(); } //close try catch (exception ex) { ex.printstacktrace(); } //close catch } //close main method } //close dbaccess class
the output rs updatable.
this doesn't work:
/* class ucan, testing ucanaccess concur_updatable. c:\jdk1.7.0_79\jre\lib\ext\ucanaccess-2.0.9.5.jar c:\jdk1.7.0_79\jre\lib\ext\hsqldb.jar c:\jdk1.7.0_79\jre\lib\ext\jackcess-2.1.0.jar c:\jdk1.7.0_79\jre\lib\ext\commons-lang-2.6.jar c:\jdk1.7.0_79\jre\lib\ext\commons-logging-1.1.1.jar present: c:\jdk1.7.0_79\jre\lib\ext\commons-logging-1.2.jar c:\jdk1.7.0_79\jre\lib\ext\commons-lang3-3.4.jar */ import java.sql.*; public class ucan { private static string dbfqn; public static void main(string[] args) { try { dbfqn = ("c:\\phil\\programming\\kpjl2002.mdb"); string database = "jdbc:ucanaccess://" + dbfqn; system.out.println("loading database: " + database); connection conn = drivermanager.getconnection(database, "", ""); statement s = conn.createstatement(resultset.type_scroll_sensitive, resultset.concur_updatable); // fetch records table string seltable = "select * " + "tbllibrary" + " order artist, cat, cart"; s.execute(seltable); resultset rs = s.getresultset(); int concurrency = rs.getconcurrency(); if(concurrency == resultset.concur_updatable) { system.out.println("rs updatable"); } else { system.out.println("rs not updatable"); } s.close(); conn.close(); } //close try catch (exception ex) { ex.printstacktrace(); } //close catch } //close main method } //close dbaccess class
the output rs not updatable. cannot update or insert rows in resultset.
the code posted operative part of larger project, ucanaccess can read table , put contents in jlist , jtextarea, formatting. when started writing code update or add new record, ran problem.
i apologize if bit long. have idea i'm missing or doing wrong?
btw, 1 of 2 fav sites good, usable java answers.
update: got idea old co-worker, original database may have been copied original access97 db. 2000 db. had used 2013 repair , compact make "new" 2002 , 2013 db's. access must retain '97 type when doing did. so, created new 2013 dummy db test, , ucanaccess report resultset updatable. try recreate record data of current db in new database file, , see if works. i'm hoping problem, since ucanaccess doesn't support updatability access97 db's. i'll let ya'll know find. thanks.
i had used 2013 repair , compact make "new" 2002 , 2013 db's. access must retain '97 type when doing did. so, created new 2013 dummy db test, , ucanaccess report resultset updatable.
the "compact , repair database" feature in access not change database file version. if have (what suspect be) older-version database file should use "save database as" feature under "file > save & publish" * convert database file newer version.
* (... @ least that's in access 2010.)
Comments
Post a Comment