libreoffice使用mysql_LibreOffice: 'com.mysql.jdbc.driver' cannot be loaded

在尝试使用LibreOffice Base通过JDBC连接到MySQL数据库时,出现'com.mysql.jdbc.driver'无法加载的错误。解决方案包括下载并注册JDBC连接器,将jar文件添加到LibreOffice的类路径,对于MariaDB则需使用不同的驱动类名。在Linux系统中,可以通过包管理器安装连接器。另外,处理DateTime字段中的'0000-00-00 00:00:00'值可能导致的问题,可以在数据库名称中添加'zeroDateTimeBehavior=convertToNull'参数。
摘要由CSDN通过智能技术生成

问题

I am trying to connect LibreOffice Base with an MySQL database, in phpMyAdmin, with a JDBC-connection.

The first step is to select which database you want to select:

810168c0a9765d84fc41f557b15ba023.png

The second step is to select which connection:

dfe39dc69829b041711b44c74d992b4c.png

The third step is to select your database:

d5fc0f255773958894ea53983b08d7e7.png

When I press 'Klasse testen' ( Test Class ), I get the following error: 'com.mysql.jdbc.driver cannot be loaded'.

Does anyone know how to avoid this error?

回答1:

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

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)

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

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)

Run LibreOffice (not Base, just LO);

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

f713f8b76dd60164eaa9a66eb8e6fc49.png

Click Add Archive;

b27ce10d6b2f74e3e11cd85162b0140a.png

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

edffceb5d07e5934f769db29106b661f.png

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

回答2:

BTW, for Mariadb everything else is the same, but the jdbc driver class changes to this:

org.mariadb.jdbc.Driver

回答3:

If you're using Red Hat like linux distros like Fedora, you can install it from the repositories with yum or dnf and then:

In Base goto Tools/Options/Java, click Classpath and select /usr/share/java/mysql-connector-java.jar in the file browser.

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

回答4:

After following the above instructions and successfully connecting to the desired MySQL database, I discovered that tables containing 0000-00-00 00:00:00 in a DateTime field generated the error 'Value 0000-00-00 00:00:00' can not be loaded as java.sql.Timestamp. Finding references to "zeroDateTimeBehavior=convertToNull" as the solution was easy; the tricky part was where to enter this in LibreOffice. The quick answer: Enter it as part of the Database name field - so 'mydatabase' would become 'mydatabase?zeroDateTimeBehavior=convertToNull'. Running under Linux Mint / Ubuntu with a localhost server, this worked wonders. Happy data crunching!

来源:https://stackoverflow.com/questions/27102600/libreoffice-com-mysql-jdbc-driver-cannot-be-loaded

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值