I am trying to establish a connection between LibreOffice (5.4.6.2) and Mariadb (10.1.29)/mysql. I have researched various resources on the web but am stuck not being able to establish a connection

preliminary steps taken:

  • the file mariadb-java-client-2.4.0.jar is downloaded from https://downloads.mariadb.com/Connectors/java/connector-java-2.3.0/
  • JRE is installed and enabled under LibreOffice Tools > Options > Advanced
  • in that Advanced tab, Class Path is set with mariadb-java-client-2.4.0.jar (I have tried with a path /opt/mariadb-java-client-2.4.0.jar and /home/<my user name>/mariadb-java-client-2.4.0.jar)

Based on web site and youtube tutorials, the next steps are to connect via LibreOffice Base. Using the wizard:

  • Connect to an existing database MySQL is chosen from the dropdown
  • after clicking Next >>
  • Under some video and how-to tutorials, there has been a third option of Connect directly... Is this a further clue that something is not set properly?
  • I choose Connect using JDBC...and click Next >>
  • I provide the database name, the server (have tried localhost and 127.0.0.1) and port number 3306
  • for the MySQL JDBC driver class I change the string to org.mariadb.jdbc.Driver according to https://stackoverflow.com/a/41842833/7932473
  • upon clicking Test Class, a dialog with The JDBC driver could not be loaded appears

I have used JDBC connections before under LO 3.x and MySQL before Mariadb came along. Ultimately, I want to use a connection to my database for further analysis of the data using Calc. Is this still possible? If my memory is not failing me, it is possible to open a Base registered database within LO Calc.

Dani AI

Generated

If Base reports "The JDBC driver could not be loaded" on LibreOffice 5.4 with MariaDB 10.1, it is almost always one of these: Java/LibreOffice bitness mismatch, the JAR not actually on LO’s classpath until a full restart, or a Connector/J version that LO 5.x cannot load. Verify that LibreOffice and Java are both 64-bit (or both 32-bit) via your distro packages and java -version. After adding the connector JAR in Tools > Options > Advanced > Class Path, quit LibreOffice completely (including the quickstarter) before testing again. If the 2.x connector still refuses to load, a 1.5.x connector is often compatible with LO 5.4-era Java. Installing a full JDK instead of only the JRE can also resolve classloading issues on some systems.

In the Base wizard, JDBC needs both a driver and a URL; they are not alternatives. The wizard fields build the URL for you, but you can also supply it explicitly. For MariaDB, the format is:

jdbc:mariadb://localhost:3306/your_db?user=your_user&password=your_pw&useUnicode=true&characterEncoding=UTF-8

Tips specific to this thread:

  • The missing "Connect directly" option comes from an old MySQL Native Connector extension; its absence is normal.
  • If localhost fails, test with 127.0.0.1, confirm port 3306 is listening, and verify credentials with the mysql client first.

Useful references: MariaDB Connector/J connection strings and LibreOffice Base JDBC guide.

Recommended Answers

All 7 Replies

I haven't done this in years but had me installing the JDK rather than the JRE. I haven't looked into this for a very long time.

From https://mariadb.com/kb/en/library/about-mariadb-connector-j/ item 4 under the Table of Contents, Requirements. There is only mention of Java.

Also, I have found that although Mariadb is a fork of MySQL and is supposedly 100% compatible, for O/JDBC use don't mix-up the two. What might work with MySQL offered by Oracle does not apply to Mariadb/MySQL.

Java Database Connectivity (JDBC). I think we don't have to cover whether or not Java is involved. I was hoping it was the old issue I ran into long ago where it didn't work at the time with the JRE but did with the JDK. Some folk lost a lot of time over that small distinction. If it doesn't apply today, that's OK. My intent was to share since I haven't worked this in some time.

I found a solution to this challenge here

It was necessary to downgrade to the MariaDB 1.5 JDBC connector

I need to give a shot JDBC, and use it to interface with my localhost MariaDB* server. I figure the Datasource URL ought to be set to either mysql://localhost:3306/or mysql://localhost:3306/mysql. Are Datasource URL and JDBC driver class two elective approaches to set up JDBC?

Thank you

That was quite uderstanding.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.