从maria db获取连接时出现以下错误:

DEBUG com.utilities.db.ConnectionPoolImpl - Exception Occured in connection: Cannot create connection:Could not connect: Client does not support authentication protocol requested by server; consider upgrading MariaDB client
Exception in thread "Thread-1" java.lang.IllegalMonitorStateException
        at java.lang.Object.notifyAll(Native Method)
        at com.utilities.db.ConnectionPoolImpl.run(ConnectionPoolImpl.java:128)
        at java.lang.Thread.run(Thread.java:745)


+-------------------------+--------------------------+
| Variable_name           | Value                    |
+-------------------------+--------------------------+
| innodb_version          | 5.6.35-80.0              |
| protocol_version        | 10                       |
| slave_type_conversions  |                          |
| version                 | 10.1.23-MariaDB-9+deb9u1 |
| version_comment         | Raspbian 9.0             |
| version_compile_machine | armv7l                   |
| version_compile_os      | debian-linux-gnueabihf   |
| version_malloc_library  | system jemalloc          |
| version_ssl_library     | YaSSL 2.4.2              |
| wsrep_patch_version     | wsrep_25.19              |
+-------------------------+--------------------------+


我正在使用Java连接到数据库。

Class.forName("org.drizzle.jdbc.DrizzleDriver");

Connection connection = DriverManager.getConnection(""jdbc:drizzle://" + ADDRESS + ":" + PORT + "/" + DB", userName, password);

Connection connection = DriverManager.getConnection(
                        "jdbc:drizzle://" + DBProperties.ADDRESS + ":" + DBProperties.PORT + "/?allowMultiQueries=true",
                        DBProperties.USER, DBProperties.PASS)

<dependency>
        <groupId>org.drizzle.jdbc</groupId>
        <artifactId>drizzle-jdbc</artifactId>
        <version>1.4</version>
    </dependency>


我不确定为什么会得到这个,有人可以帮助我吗?

最佳答案

请尝试并遵循https://mariadb.com/kb/en/library/about-mariadb-connector-j/中的建议

我将从您的Maven依赖项中删除毛毛雨驱动程序,并包括最新版本的mariaDB连接器

<dependency>
    <groupId>org.mariadb.jdbc</groupId>
    <artifactId>mariadb-java-client</artifactId>
    <version>2.2.3</version>
</dependency>


然后,我将您的客户代码替换为官方示例:

Connection connection = DriverManager.getConnection("jdbc:mariadb://localhost:3306/DB?user=foo&password=bar");


具有适当的端口,用户等值。我希望你觉得它有用

关于java - 无法创建连接:无法连接:客户端不支持服务器请求的身份验证协议(protocol),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49631605/

10-14 13:49
查看更多