How to connect to a MySQL database from LibreOffice using JDBC on Slackware Linux

The LibreOffice Base application gives us the opportunity to work with MySQL databases in a graphical interface. I especially find the “Query Design View” useful when working on larger MySQL databases.

This tutorial demonstrates how configure the MySQL Connector/J (which is the official JDBC driver for MySQL) on Slackware 14.1 x86_64.

Tested on:
Slackware 14.1 x86_64
Java Platform (JDK) 8u45
LibreOffice 4.4.3.2
mysql-connector-java-5.1.35 (JDBC)

Tl;dr

Get the compressed highlights from Youtube: https://youtu.be/Cm_p9tji8Vo

Prerequisites

On Slackware it’s necessary to comment out the SKIP=”–skip-networking” directive from MariaDB which is enabled by default.

vi /etc/rc.d/rc.mysqld
# SKIP="--skip-networking"
/etc/rc.d/rc.mysqld restart

Failure to do so will result in the following error message when using the JDBC driver:

SQL Status: 08S01
Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server

Install the JDBC driver

Get the required software from the following locations:
Download Connector/J
Java SE Downloads
MySQL Mirrors

# Download the JDBC driver from a MySQL mirror
wget -q ftp://mirrors.dotsrc.org/mysql/Downloads/Connector-J/mysql-connector-java-5.1.35.tar.gz

# Download the JDBC driver checksum file
wget -q ftp://mirrors.dotsrc.org/mysql/Downloads/Connector-J/mysql-connector-java-5.1.35.tar.gz.md5

# Verify the integrity of the downloaded file
md5sum -c mysql-connector-java-5.1.35.tar.gz.md5

# Extract only the JAR file without its parent folder
tar -zxf mysql-connector-java-5.1.35.tar.gz mysql-connector-java-5.1.35/mysql-connector-java-5.1.35-bin.jar --strip-components=1

# Move the JAR file to the extensions folder
mv mysql-connector-java-5.1.35-bin.jar /usr/lib64/java/jre/lib/ext/

# Delete the files we no longer need
rm mysql-connector-java-5.1.35.tar*

Configure the JDBC driver for use with LibreOffice

Make sure that LibreOffice is using a java runtime environment. Navigate to “Options” => “Advanced” and verify the configuration.

Start the Base application and choose the option to connect to an existing database by selecting the JDBC driver.

Specify the datasource and driver class on the following format:
DataSource URL: mysql://host/db_name_here
JDBC Driver class: com.mysql.jdbc.Driver
Click on “Test class” to verify that the driver is working.

Finally, configure user authentication against the chosen database. Fill in your username and tick the “Password required” field. Click on “Test connection” to verify your credentials.

The process in pictures:

Thank you for reading!
Feel free to waste more time by subscribing to my RSS feed or check out the human-readable sitemap for more content.

Related posts