LibreOffice: 'com.mysql.jdbc.driver' cannot be loaded

老子叫甜甜 提交于 2019-12-20 09:53:24

问题


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:

The second step is to select which connection:

The third step is to select your database:

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:

  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;

  6. Click Add Archive;

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!