Skip to content

Instantly share code, notes, and snippets.

@danielTobon43
Created February 6, 2022 12:16
Show Gist options
  • Save danielTobon43/fa0104ec0333886d2a4a9dd4a4ff05f7 to your computer and use it in GitHub Desktop.
Save danielTobon43/fa0104ec0333886d2a4a9dd4a4ff05f7 to your computer and use it in GitHub Desktop.

Open Access database (accdb) ubuntu 20.04 Libreoffice Base

We can use the UCanAccess JDBC driver to connect to Access databases (.mdb and .accdb) in LibreOffice Base. Here's how I did it on a clean install of Ubuntu 20.04 LTS.

One-Time Setup

First, I installed LibreOffice Base

sudo apt-get install libreoffice-base

Then I downloaded UCanAccess (bin.zip file) and unzipped it into the folder

~/Downloads/JDBC/UCanAccess

O96Bs

Note: When unzipping the distribution file be sure to specify "Keep directory structure" (or similar, depending on your unzip tool) so the folder structure appears as in the screenshot above.

I launched LibreOffice (not Base, just LibreOffice itself)

29Sow

and chose Tools > Options

X3zj6

On the Advanced tab I clicked the "Class Path..." button

GdmOn

and then added the following JAR file using the "Add Archive..." button:

/home/gord/Downloads/JDBC/UCanAccess/loader/ucanload.jar

1pvWH

Note that this is ucanload.jar in the loader/ subfolder, not "ucanaccess-x.y.z.jar” in the UCanAccess home folder.

Important: You must close and re-open all LibreOffice (or OpenOffice.org) components for the new "Class Path...” value to take effect. That includes any "quick start” features or other related processes. (If you want to play it safe, simply restart your machine.)

Per-Database Setup

I launched LibreOffice Base, and in Step 1 of the wizard I chose "Connect to an existing database (JDBC)"

LuW4i

The Access file I wanted to manipulate was named "uca301demo.accdb" in my Documents folder, so in Step 2 the "Datasource URL" was …

ucanaccess:///home/gord/Documents/uca301demo.accdb

(note that Base supplies the jdbc: prefix for us, so all we need to enter is the remainder of the URL starting with ucanaccess: …)

… and the "JDBC driver class" was

net.ucanaccess.jdbc.UcanloadDriver

6qE1y

In Step 3, I left the "User name" field empty and just clicked "Next >>".

In Step 4, I saved the LibreOffice Base database as "accdbTest.odb" in my Documents folder.

When the wizard completed it opened my LibreOffice database and I could see the tables and saved queries in the .accdb file

EXrXU

Troubleshooting

If you are using a distribution that installs LibreOffice Base by default (e.g., Linux Mint) then you may receive the error

    The connection to the data source "MyDatabase" could not be established.

    'org.hsqldb.persist.HsqlProperties org.hsqldb.DatabaseURL.parseURL(java.lang.String, boolean, boolean)'

That is because LibreOffice has installed its own (rather old) copy of HSQLDB that conflicts with UCanAccess. To fix that, remove LibreOffice's copy of HSQLDB. For example, on Linux Mint that would be

sudo apt remove libhsqldb1.8.0-java

Also, if LibreOffice Base won't work for whatever reason you can use DBeaver instead. Installing the (free) Community Edition is as easy as

sudo snap install dbeaver-ce

Reference

Is it possible to open an Access 2010 database file without using Wine or VirtualBox?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment