Fork me on GitHub

Jackcess

Jackcess is a pure Java library for reading from and writing to MS Access databases (currently supporting versions 2000-2019). It is not an application. There is no GUI. It's a library, intended for other developers to use to build Java applications. Jackcess is licensed under the Apache License (as of version 2.1.0) and currently requires Java 8+ (as of the 3.0.0 release) Take a look at our Frequently Asked Questions for more info.

Java 9+ Compatibility (2021-01-20)

While Jackcess still only requires Java 8+, as of the 4.0.0 release it now includes an Automatic-Module-Name of com.healthmarketscience.jackcess in its manifest. This allows it to be used safely in the module path for Java 9+ projects.

This release is binary compatible with the 3.x release series.

Java 8+ Support (2019-02-08)

Jackcess now requires Java 8+ as of the 3.0.0 release. All third party dependencies have been updated to the latest versions. Jackcess now supports Java 8+ data types like LocalDateTime and Path. Databases can now optionally return Date values (legacy, backwards compatible) or LocalDateTime values. See DateTimeType and the Upgrade Guide for more details

Expression Evaluation (2018-09-08)

Have you ever wished that Jackcess could handle field "default values" (or other expressions)? Wish no longer! Expression evaluation is now enabled by default as of the 3.5.0 release. See the expression package javadocs for more details.

Brand New License! (2015-04-16)

Due to the generosity of Health Market Science and the efforts of the Apache Tika project, the OpenHMS projects have been relicensed under the Apache License, Version 2.0 (Jackcess versions 2.1.0 and higher).

Sample code

Here are a few snippets of code to whet your appetite. For more extensive examples, checkout the cookbook. And, since Jackcess is heavily unit tested, you can find even more example code in the unit tests.

  • Iterating through the rows of a table:
    Table table = DatabaseBuilder.open(new File("my.mdb")).getTable("MyTable");
    for(Row row : table) {
      System.out.println("Column 'a' has value: " + row.get("a"));
    }
    
  • Searching for a row with a specific column value:
    Row row = CursorBuilder.findRow(table, Collections.singletonMap("a", "foo"));
    if(row != null) {
      System.out.println("Found row where 'a' == 'foo': " + row);
    } else {
      System.out.println("Could not find row where 'a' == 'foo'");
    }
    
  • Creating a new table and writing data into it:
    Database db = DatabaseBuilder.create(Database.FileFormat.V2000, new File("new.mdb"));
    Table newTable = new TableBuilder("NewTable")
      .addColumn(new ColumnBuilder("a", DataType.LONG))
      .addColumn(new ColumnBuilder("b", DataType.TEXT))
      .toTable(db);
    newTable.addRow(1, "foo");
    
  • Copying the contents of a JDBC ResultSet (e.g. from an external database) into a new table:
    Database db = DatabaseBuilder.open(new File("my.mdb"));
    new ImportUtil.Builder(db, "Imported").importResultSet(resultSet);
    db.close();
  • Copying the contents of a CSV file into a new table:
    Database db = DatabaseBuilder.open(new File("my.mdb"));
    new ImportUtil.Builder(db, "Imported2").setDelimiter(",").importFile(new File("my.csv"));
    db.close();

Other Resources

Some other jackcess related projects:

  • mdbtools - Open Source project for reading Access files, written in C.
  • Jackcess Encrypt - Extension library for Jackcess which implements support for some forms of Microsoft Access and Microsoft Money encryption.
  • UCanAccess - Open Source pure Java JDBC Driver implementation.