How do I set up a JDBC connector for MariaDB (or MySQL) in Base?

While that may be true, there are other softwares which either require or benefit from JDK, it usually won’t hurt to have it instead. Also, at least on Ubuntu, there’s no way to install just JRE the canon way. I think they came to the same conclusion: shouldn’t hurt having JDK.

Other software doesn’t necessarily have anything to do with LO. While installing JDK instead of JRE is not a problem (JRE is in JDK) the download is three times larger and occupies more resources. The point is, JDK is not usually needed for LO. I’m on Xubuntu and Mint. I install from Oracle and LO. Seen a number of problems using distro installs.

Interesting. Humm? Glad to hear that the Relationship issue is confirmed. Thank you. Also noticed Edit | Database Properties has same basic info, but looks a bit different depending on JDBC, or MYSQL|JDBC setup. Possibly missing or different connection parameters?? For what it’s worth, did you try org.mariadb.jdbc.Driver for the driver path, when used w/ classpath: /usr/share/java/mariadb-java-client-1.5.7.jar?

Yes tried everything I could imagine with the maria db connector. Nothing worked. The worst was the web site. Sign in, ask for 1.5.3 and still get 1.5.7.

@Ratslinger, My bad. Revised my answer, and my comment to you above last night, but comment revisions didn’t seem to take. → I have moved from 1.5.3.jar up to 1.5.7.jar. Also, sorry, but I had a mistake showing above. Was showing wrong driver path. Again, corrected to: use with /usr/share/java/mariadb-java-client-1.5.7.jar with org.mariadb.jdbc.Driver. Appreciate you checking my work.

MariaDB connector was my fault. I was trying to use com.mariadb.jdbc.Driver. org works fine. Also confirmed my suspicions - mariadb-java-client-1.5.7.jar can be located wherever wanted. I keep it in my home directory. Also confirmed MariaDB works with SQL Workbench/J (I use this more than any other). Good news as there is a lack of good tools (my opinion) for it in Linux.

@ratslinger yes that is right. I made this mistake too, at first

Everywhere you see com.mysql.jdbc… you need to change to org.mariadb.jdbc…

As well as changing the name when they forked, they mover from com to org top level just to rub in the point that they are not-for-profit :wink:

@trueriver Of course it is right as I stated so in my comment. Don’t see the purpose of the comment. I don’t even use MariaDB. Only did here for testing purposes to answer question. Actually moving away from MySQL also. Have been running parallel testing with both PostgreSQL & Firebird server.

  • [Update: Tried to also get this to work in OpenOffice but failed. Some notes in 1st paragraph below. May 30, 17]
  • [Update: Only one of the two possible methods of connecting with JDBC allows relationships to work. See below under step 4. - Feb 3, 2017 ]
  • [Update: Includes information for both Windows and Linux. - Jan 23, 2016]

STEP BY STEP

This is tested to work for Mariadb 10.1 running on a dual boot Linux Debian 8.6/Windows 10. (Also below are some tips for possibly using MySQL). EDIT: I tried to get this to work on OpenOffice 4.1.3, but can’t. First it wanted me to select the java class path archive in the home space rather than the root. I was able to manually type in the real address for it from the root. But then I got stopped when I tried to open the database below after I had entered the correct info in, especially “org.mariadb.jdbc.Driver”, but it comes back with the wrong driver class:

image description


1) If you don’t already have it installed, install MariaDB from here. (I have the Debian Linux MariaDB 10.1 Series installed.)

Test MariaDB:

  • In linux:
mysql -u [your username, normally 'root'] --password='[your password]'

You should get a prompt, and enter something like:

MariaDB [(none)]> show databases;

+--------------------+
| Database           |
+--------------------+
| bigbase            |
| information_schema |
| mysql              |
| performance_schema |
| phpmyadmin         |
+--------------------+

MariaDB [(none)]> quit

  • In Windows 10, I don’t know of a similar command line test, however you can use HeidiSQL.

  • Also in Linux HeidiSQL works nicely under Wine. (I think I like it better than phpMyAdmin.)

Data base settings are in /etc/mysql/my.cfg (in Linux), and in C:\ProgramData\MySQL\MySQL Server 5.6\my.ini (in Windows). You’ll want to have the server stopped while editing these, especially if moving the path to the database files by changing the datadir parameter.

You can stop, start or re-start the MariaDB server as follows:

a) In Linux:

sudo service mysql stop
sudo vi /etc/mysql/my.cfg
sudo service mysql start

b) In Windows:

Start | Find `Services` | Scroll down to `MySQL56` and right click on it for options to stop, restart, etc.

2) Download and install the MariaDB JDBC connector jar file from here. I have the MariaDB Connector/J 1.5 Series (v 1.5.7) installed. You’re looking for the “Universal” OS version (it’s Java after all and will run on any OS), not the source, but you can also get the source if you like to peek inside to investigate the file hierarchy naming which will be used below. The important thing is you need the mariadb-java-client-1.5.7.jar file (v1.5.3 ok too). (It’s a little confusing because it’s sometimes called a connector, and sometimes a client, and it’s both.)

  • On Linux Debian copy this jar file into /usr/share/java/. (I had a hard time finding where to copy it to. Another post suggested this location. Perhaps you could search your system for jar files. Or perhaps someone else can suggest how to determine where to put it.

  • On Windows copy this jar file into C:\Java\ (This is the suggested location, and because it is processor independent, it makes more sense than putting it into either of the two normal program file locations, i.e. C:\Program Files (x86)\ (which holds 32 bit programs) or C:\Program Files\ (which holds 64 bit programs).


3) Open LibreOffice (not LibreOffice Base, just LibreOffice) and go to Tools | Options | LibreOffice | Advanced | Set Classpath..., and click Add Archive (to add a specific Jar file, rather than a directory of them), then enter:

  • For Linux: /usr/share/java/mariadb-java-client.1.5.7.jar

  • For Windows: C:\Java\mariadb-java-client.1.5.7.jar


4) Setup your database for use. Go to File | New | Database. Select Connect to an existing database.

Tip: From here, there are two different ways to proceed: You can simply select a) JDBC, or b) you can firsts select MySQL and then JDBC. Method "a: allows you to view, open and edit your tables, but has a bug and does not allow table-to-table relationships to be viewed, edited, or work properly in subforms. If you choose method a you will get this error message when you select Tools,Relationships...

image description


4a) Method a: Select JDBC (Direct method. Disables relationships!):


4b) Method b: Select MySQL then JDBC (This method makes relationships work properly):

This does the same thing as in 4a above, it just asks a few different questions to get there.

Note, in the following screen the “Connect directly” option is now gone. Not sure why. (Think it might have to do with using the MariaDB Driver rather than the MySQL Driver.)

The Database name, Server, and Port number combine into what’s called the Datasource URL like this: mysql://hostname:port/database_name. (Notes: Perhaps someday this will use mariadb://.... But for now enter mysql://... even for MariaDB. Note, the URL seems to work even when you don’t have a web server setup. I’m guessing because we’re talking to localhost. You can also use 127.0.0.1 instead of localhost.

The JDBC Driver Class needs: “org.mariadb.jdbc.Driver” for the MariaDB JDBC driver, or (“com.mysql.jdbc.Driver” when using the MySQL JDBC driver). (You can open up the jar file and drill down into the file hierarchy to see that the folder com contains mariadb contains jdbc contains the Driver.java file.)

Also note that the free MariaDB database stuff is at their .org site, and commercial MariaDB stuff is at their .com web site.

Then save your new *.odb database file in an appropriate location and give it a better name. I suggest you name it JDBC-<some name> so you know that this is a JDBC connected database. You can use this file to later open this database with the JDBC connnector. (I don’t know why it says, ODF Database at the lower right of the screen, as it will be an .odb file you create.)

5) The results:

If all goes well you should get a screen like this:


6) Inspecting your databases properties. Finally, you can inspect how your database is setup as follows:

7) Edit | Database properties... gives:

image description

image description

I’m not sure what you could mean by “…I was really looking for a more comprehensive answer…” because the link I provided contained all of what you stated & more (including how to find out “…how the JDBC Driver Class of “com.mysql.jdbc.Driver” is arrived at…”). If you wanted “pictures” I would have pointed you here - Creating a DB but it doesn’t have the links for the connectors.

Before you re-write more of the existing documentation, you may want to peruse what is in existence - click here.

@EasyTrieve - sometimes good to have details but if you look at my edited answer things can change.

@EasyTrieve Just found this today while testing different DB performance on different. You may know this already but just in case I’ll pass it on. Native is the best way to connect - many times faster through my testing. While testing MariaDB the current MySQL native connection (pre-installed as SDBC driver for Apache Office 1.2.0) would not connect. Did find this one which did work -click here.

The problem is that it replaces the installed one and I can’t seem to find where to get the original again. Even reloading LO didn’t work. To me that is a problem because the one which works for MariaDB in v5.2.3.3 doesn’t work for MySQL in that LO version.

Again, you may already know of this. If not it may be worthwhile. It’s quite a bit faster.

@EasyTrieve Just a correction. Retested 1.2.0 connector and it worked without a problem on Debian with MariaDB. Seems the first time I tried this it failed because there actually was NO Native connector present. I also found my copy of the .otx so I have it if needed.

@Easytrieve The aforementioned Native connector works in connecting to AOO, and again, it is much faster than JDBC connection. Also, using mysql-connector-java-5.1.35-bin.jar I had no problem with JDBC connection leaving com.mysql.jdbc.Driver as is.

@Ratslinger, I hear you but I’m confused. If you install this does it mess up LO, "The problem is that it replaces the installed one and I can’t seem to find where to get the original again. "? Also it only says works with LO 4.2 & 4.3. ?? My memory is failing, but I thought there used to be a native option and it was removed for some reason. Now I don’t see Native under Connect to an existing database. Also looks like you are running w/ mysql (oracle) driver, not maria ?

@EasyTrieve Sorry for the confusion. The v1.2 is what works for both LO & AOO. The location is here. As for the JDBC, the Oracle works with AOO & MariaDB but the Maria connector does not.

End of step 4: your uncertainty about ODF

ODF is a generic term not an actual file extension. It stands for Open Document Foundation or Open Document Format depending on the context. So an ODF spreadsheet has an extension .ods for example, an ODF database. odb, and so on. LO and OO both use ODF formats by default

Hope that clarifies