22

我正在尝试通过 JDBC 连接将 LibreOffice Base 与 phpMyAdmin 中的 MySQL 数据库连接起来。

第一步是选择要选择的数据库:步骤1

第二步是选择哪个连接:第2步

第三步是选择你的数据库:第 3 步

当我按“Klasse testen”(测试类)时,出现以下错误:“com.mysql.jdbc.driver 无法加载”。

有谁知道如何避免这个错误?

4

5 回答 5

44

You need to download and "register" the JDBC connector first. To do so:

  1. Go to http://dev.mysql.com/downloads/connector/j/ and download the ZIP archive with the JDBC connector ("Platform-Independent"); you may alternatively download the MSI installer; in this case, the jar file can be found in Program Files (x86)/MySQL/MySQL Connector J/ (assuming a Win 7 64bit system)

  2. Unzip the archive on your local PC (remember the path to its contents), or alternatively install the MSI file;

  3. In the extracted folder structure, there's a file "mysql-connector-java-5.0.8-bin.jar" (name depends on the exact version you've downloaded)

  4. Run LibreOffice (not Base, just LO);

  5. Open Menu Tools -> Options -> LibreOffice -> Advanced -> Class Path;

    enter image description here

  6. Click Add Archive;

    enter image description here

  7. Select the jar file from step 1-3 and hit OK. Now, the Class Pathdialog should look as follows:

    enter image description here

That's it. Now, LO knows where to look for the MySQL JDBC Driver.

于 2014-11-24T11:42:31.240 回答
6

顺便说一句,对于Mariadb ,其他一切都相同,但 jdbc 驱动程序类更改为:

org.mariadb.jdbc.Driver
于 2017-01-25T03:20:23.243 回答
4

如果您使用 Red Hat 之类的 Linux 发行版(例如 Fedora),您可以使用 yum 或 dnf 从存储库安装它,然后:

在 Base goto Tools/Options/Java 中,单击 Classpath 并在文件浏览器中选择 /usr/share/java/mysql-connector-java.jar。

https://fedoraproject.org/wiki/QA:Testcase_MySQL_or_MariaDB_in_libreoffice-base

于 2016-07-22T17:06:29.440 回答
2

按照上述说明并成功连接到所需的 MySQL 数据库后,我发现在 DateTime 字段中包含 0000-00-00 00:00:00 的表会生成错误“Value 0000-00-00 00:00:00”可以不加载为 java.sql.Timestamp。找到对“zeroDateTimeBehavior=convertToNull”的引用作为解决方案很容易;棘手的部分是在 LibreOffice 中输入此内容的位置。快速回答:将其作为数据库名称字段的一部分输入 - 因此“mydatabase”将变为“mydatabase?zeroDateTimeBehavior=convertToNull”。在带有本地主机服务器的 Linux Mint / Ubuntu 下运行,这创造了奇迹。快乐的数据处理!

于 2015-04-07T19:41:18.923 回答
0

在我的情况下(Windows 和 Linux),问题是 JRE / JDK 和 LibreOffice 的组合。

它与 LibreOffice-7.0.3.1、JRE-1.0.8.281、mysql-connector-java-8.0.18.jar 一起使用。当我升级到LibreOffice-7.2无法加载JRE-1.0.8.301JDBC驱动程序时。

所以我切换到 LibreOffice-7.0.5.1 和 JRE-1.0.8.281 并且看起来不错。我没有尝试过更新版本的 JRE(282 到 300)。

在 LibreOffice,他们提供 7.2、7.1 和 7.0 版本。

所以它适用于 Win-32 位和 64 位的 LibreOffice-7.0.5.1(32 位,最新的 7.0 系列)、JRE-1.8.0.281(32 位不是最新的)和 mysql-connector-java-8.0.26。罐子(最新)。我想问题出在 mysql-connector-java-8.0-26.jar 上。也许它需要用最新的 JDK 重新编译?我试过了,但我没有时间安装依赖项。

使用 Linux 64 位,它适用于:LO-6.2.8.2、JDK-1.0.8.261、mysql-java-connector-8.0.18.jar(懒得升级所有这些)。尝试使用 JDK-1.0.8.301 = KABOOM!

于 2021-08-27T08:22:38.550 回答