Help Center/ TaurusDB/ Troubleshooting/ Connection Issues/ Failed to Connect to a Database Using mariadb-connector in SSL Mode
Updated on 2024-09-05 GMT+08:00

Failed to Connect to a Database Using mariadb-connector in SSL Mode

Scenario

A database could not be connected using JDBC, and the following error message was displayed:

unable to find certification path to requested target

Possible Causes

As shown in the figure above, the JAR package of MariaDB is used to connect to the database, which is slightly different from the official driver package of MySQL.

Solution

The connection string for MariaDB is as follows:
String url = "jdbc:mysql://xxx.xxx.xxx.xxx:xxxx/mysql?useSsl=true&serverSslCert=D:\\ca.pem&disableSslHostnameVerification=true";

Note: GaussDB(for MySQL) instances do not support hostname verification. Therefore, you need to set disableSslHostnameVerification to true. The setting method varies depending on the MariaDB JAR package version. For details, see the notes on usage of the corresponding version.