Configure ODBC and JDBC in LibreOffice Base
LibreOffice Base allows users to connect to external relational database management systems (RDBMS) using Open Database Connectivity (ODBC) and Java Database Connectivity (JDBC). This guide details the essential driver requirements, system prerequisites, and step-by-step configuration procedures needed to establish stable ODBC and JDBC connections within LibreOffice Base.
System Prerequisites
Before configuring either driver, ensure the following conditions are met:
- Architecture Match: The bit architecture of LibreOffice, the Java Runtime Environment (JRE), and the external database drivers must match. If you are using 64-bit LibreOffice, you must install 64-bit ODBC/JDBC drivers and a 64-bit JRE.
- Java Runtime Environment (for JDBC): Open LibreOffice, navigate to Tools > Options > LibreOffice > Advanced (or LibreOffice > Preferences on macOS), ensure Use a Java runtime environment is checked, and select an installed JRE.
JDBC Driver Configuration
JDBC connects to databases via Java archives (.jar
files) provided by the database vendor (e.g., MySQL Connector/J,
PostgreSQL JDBC Driver).
Step 1: Add the JDBC Driver to LibreOffice ClassPath
- Download the appropriate
.jardriver file from your database provider. - In LibreOffice, go to Tools > Options > LibreOffice > Advanced.
- Click the Class Path… button on the right.
- Click Add Archive…, browse to the location of your
downloaded
.jarfile, select it, and click Open. - Click OK, then click OK again. Restart LibreOffice to apply changes.
Step 2: Connect LibreOffice Base via JDBC
- Open LibreOffice Base to launch the Database Wizard.
- Select Connect to an existing database, choose JDBC from the dropdown menu, and click Next.
- Enter the Datasource URL and the JDBC
driver class:
- MySQL / MariaDB:
- URL:
mysql://<hostname>:<port>/<database_name> - Driver Class:
com.mysql.cj.jdbc.Driver
- URL:
- PostgreSQL:
- URL:
postgresql://<hostname>:<port>/<database_name> - Driver Class:
org.postgresql.Driver
- URL:
- MySQL / MariaDB:
- Click Test class to verify that the driver class loads successfully.
- Click Next, enter your database username, check Password required if applicable, and click Test Connection to confirm connectivity.
- Click Finish and save the
.odbfile.
ODBC Driver Configuration
ODBC connects via drivers installed at the operating system level, identified by a Data Source Name (DSN).
Step 1: Install and Configure the ODBC Driver on the OS
- Install the appropriate ODBC driver package for your database (e.g., MySQL ODBC Connector, PostgreSQL psqlODBC).
- Configure a Data Source Name (DSN):
- Windows: Open ODBC Data Source Administrator (64-bit), go to the System DSN or User DSN tab, click Add, select your driver, configure host/database/credentials, and name the DSN.
- Linux / macOS: Define the DSN in
/etc/odbc.inior~/.odbc.iniusing the unixODBC or iODBC driver manager.
Step 2: Connect LibreOffice Base via ODBC
- Open LibreOffice Base to launch the Database Wizard.
- Select Connect to an existing database, choose ODBC from the dropdown menu, and click Next.
- Click Browse… to view the list of configured ODBC data sources and select your DSN.
- Click Next, enter the required username, and click Test Connection to verify the link.
- Click Finish and save the
.odbfile to complete the setup.