Menu

#123 NullPointerException with getTable on linked table when sort order not General

2.1.1
closed
None
1
2015-04-21
2015-04-21
No

Further to:

http://sourceforge.net/p/ucanaccess/discussion/help/thread/85e8e178/

If an .accdb file

  • has a sort order that is not "General" or "General - Legacy", and
  • contains linked tables

then trying to use Database#getTable on the linked table results in a NullPointerException:

public static void main(String[] args) {
    try (Database db = DatabaseBuilder.open(new File("C:/Users/Public/test/linked.accdb"))) {
        Table tbl = null;
        try {
            tbl = db.getTable("Table1");
        } catch (NullPointerException npe) {
            System.err.println("*** ERROR - .getTable threw NullPointerException:");
            npe.printStackTrace(System.err);
            System.exit(0);
        }
        for (Row r : tbl) {
            System.out.println(r.getString("TextField"));
        }
    } catch (Exception e) {
        e.printStackTrace(System.err);
    }
}

 
result:

*** ERROR - .getTable threw NullPointerException:
java.lang.NullPointerException
    at java.io.File.<init>(File.java:277)
    at com.healthmarketscience.jackcess.util.LinkResolver$1.resolveLinkedDatabase(LinkResolver.java:42)
    at com.healthmarketscience.jackcess.impl.DatabaseImpl.getTable(DatabaseImpl.java:956)
    at com.healthmarketscience.jackcess.impl.DatabaseImpl.getTable(DatabaseImpl.java:900)
    at com.healthmarketscience.jackcess.impl.DatabaseImpl.getTable(DatabaseImpl.java:80)
    at com.example.jackcesstest.ComExampleJackcesstest.main(ComExampleJackcesstest.java:27)

 
Changing the sort order of the database file to "General" or "General - Legacy" avoids the error.

Discussion

  • James Ahlborn

    James Ahlborn - 2015-04-21

    Fixed in trunk, will be in the 2.1.1 release.

     
  • James Ahlborn

    James Ahlborn - 2015-04-21
    • status: open --> closed
    • assigned_to: James Ahlborn
    • Group: Unassigned --> 2.1.1
     

Log in to post a comment.

MongoDB Logo MongoDB