英文:
Unable to acquire connection from data source(Hibernate + Hikari + MySQL)
问题
我正在尝试使用Hikari作为连接池连接到本地的MySQL数据库,但无法建立连接。
有人可以告诉我我做错了什么吗?
MySQL版本:
mysql Ver 8.0.21 for Linux on x86_64 (MySQL Community Server - GPL)
项目中的依赖项如下:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-hikaricp</artifactId>
<version>5.3.6.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.21</version>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.7.6</version>
</dependency>
HikariCP启动日志:
2020-08-04 19:09:31.089 DEBUG [main] [com.zaxxer.hikari.HikariConfig] chapuceros-pool - configuration:
2020-08-04 19:09:31.091 DEBUG [main] [com.zaxxer.hikari.HikariConfig] allowPoolSuspension.............false
2020-08-04 19:09:31.091 DEBUG [main] [com.zaxxer.hikari.HikariConfig] autoCommit......................true
2020-08-04 19:09:31.091 DEBUG [main] [com.zaxxer.hikari.HikariConfig] catalog.........................none
2020-08-04 19:09:31.091 DEBUG [main] [com.zaxxer.hikari.HikariConfig] connectionInitSql...............none
2020-08-04 19:09:31.091 DEBUG [main] [com.zaxxer.hikari.HikariConfig] connectionTestQuery............."/* ping */"
...
2020-08-04 19:09:31.093 DEBUG [main] [com.zaxxer.hikari.HikariConfig] validationTimeout...............5000
错误摘要:
[main] [com.zaxxer.hikari.HikariDataSource] chapuceros-pool - Starting...
[com.zaxxer.hikari.pool.PoolBase] chapuceros-pool - Failed to create/setup connection: Communications link failure
[com.zaxxer.hikari.pool.HikariPool] chapuceros-pool - Cannot acquire connection from data source
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
Caused by: java.net.SocketException: Broken pipe (Write failed)
英文:
I'm trying to connect to a local MySql database using Hikari as the connection pool but I am unable to establish the connection.
Can someone tell me what I'm doing wrong?
MySql Version:
mysql Ver 8.0.21 for Linux on x86_64 (MySQL Community Server - GPL)
The dependencies in the project are as follows:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-hikaricp</artifactId>
<version>5.3.6.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.21</version>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.7.6</version>
</dependency>
HikariCP Startup log:
2020-08-04 19:09:31.089 DEBUG [main] [com.zaxxer.hikari.HikariConfig] chapuceros-pool - configuration:
2020-08-04 19:09:31.091 DEBUG [main] [com.zaxxer.hikari.HikariConfig] allowPoolSuspension.............false
2020-08-04 19:09:31.091 DEBUG [main] [com.zaxxer.hikari.HikariConfig] autoCommit......................true
2020-08-04 19:09:31.091 DEBUG [main] [com.zaxxer.hikari.HikariConfig] catalog.........................none
2020-08-04 19:09:31.091 DEBUG [main] [com.zaxxer.hikari.HikariConfig] connectionInitSql...............none
2020-08-04 19:09:31.091 DEBUG [main] [com.zaxxer.hikari.HikariConfig] connectionTestQuery............."/* ping */"
2020-08-04 19:09:31.091 DEBUG [main] [com.zaxxer.hikari.HikariConfig] connectionTimeout...............30000
2020-08-04 19:09:31.091 DEBUG [main] [com.zaxxer.hikari.HikariConfig] dataSource......................none
2020-08-04 19:09:31.091 DEBUG [main] [com.zaxxer.hikari.HikariConfig] dataSourceClassName.............none
2020-08-04 19:09:31.092 DEBUG [main] [com.zaxxer.hikari.HikariConfig] dataSourceJNDI..................none
2020-08-04 19:09:31.092 DEBUG [main] [com.zaxxer.hikari.HikariConfig] dataSourceProperties............{autoReconnectForPools=true, cacheServerConfiguration=true, useServerPrepStmts=true, elideSetAutoCommits=true, user=chapucerodev, rewriteBatchedStatements=true, cachePrepStmts=true, cacheResultSetMetadata=true, useLocalSessionState=true, maintainTimeStats=false, prepStmtCacheSize=250, prepStmtCacheSqlLimit=2048, password=<masked>, useLocalTransactionState=true}
2020-08-04 19:09:31.092 DEBUG [main] [com.zaxxer.hikari.HikariConfig] driverClassName................."com.mysql.cj.jdbc.Driver"
2020-08-04 19:09:31.092 DEBUG [main] [com.zaxxer.hikari.HikariConfig] healthCheckProperties...........{}
2020-08-04 19:09:31.092 DEBUG [main] [com.zaxxer.hikari.HikariConfig] healthCheckRegistry.............none
2020-08-04 19:09:31.092 DEBUG [main] [com.zaxxer.hikari.HikariConfig] idleTimeout.....................90000
2020-08-04 19:09:31.092 DEBUG [main] [com.zaxxer.hikari.HikariConfig] initializationFailFast..........true
2020-08-04 19:09:31.092 DEBUG [main] [com.zaxxer.hikari.HikariConfig] initializationFailTimeout.......1
2020-08-04 19:09:31.092 DEBUG [main] [com.zaxxer.hikari.HikariConfig] isolateInternalQueries..........false
2020-08-04 19:09:31.092 DEBUG [main] [com.zaxxer.hikari.HikariConfig] jdbc4ConnectionTest.............false
2020-08-04 19:09:31.093 DEBUG [main] [com.zaxxer.hikari.HikariConfig] jdbcUrl.........................jdbc:mysql://localhost:3306/TEST_DB
2020-08-04 19:09:31.093 DEBUG [main] [com.zaxxer.hikari.HikariConfig] leakDetectionThreshold..........0
2020-08-04 19:09:31.093 DEBUG [main] [com.zaxxer.hikari.HikariConfig] maxLifetime.....................120000
2020-08-04 19:09:31.093 DEBUG [main] [com.zaxxer.hikari.HikariConfig] maximumPoolSize.................30
2020-08-04 19:09:31.093 DEBUG [main] [com.zaxxer.hikari.HikariConfig] metricRegistry..................none
2020-08-04 19:09:31.093 DEBUG [main] [com.zaxxer.hikari.HikariConfig] metricsTrackerFactory...........none
2020-08-04 19:09:31.093 DEBUG [main] [com.zaxxer.hikari.HikariConfig] minimumIdle.....................1
2020-08-04 19:09:31.093 DEBUG [main] [com.zaxxer.hikari.HikariConfig] password........................<masked>
2020-08-04 19:09:31.093 DEBUG [main] [com.zaxxer.hikari.HikariConfig] poolName........................"chapuceros-pool"
2020-08-04 19:09:31.093 DEBUG [main] [com.zaxxer.hikari.HikariConfig] readOnly........................false
2020-08-04 19:09:31.093 DEBUG [main] [com.zaxxer.hikari.HikariConfig] registerMbeans..................false
2020-08-04 19:09:31.093 DEBUG [main] [com.zaxxer.hikari.HikariConfig] scheduledExecutor...............none
2020-08-04 19:09:31.093 DEBUG [main] [com.zaxxer.hikari.HikariConfig] scheduledExecutorService........internal
2020-08-04 19:09:31.093 DEBUG [main] [com.zaxxer.hikari.HikariConfig] schema..........................none
2020-08-04 19:09:31.093 DEBUG [main] [com.zaxxer.hikari.HikariConfig] threadFactory...................internal
2020-08-04 19:09:31.093 DEBUG [main] [com.zaxxer.hikari.HikariConfig] transactionIsolation............default
2020-08-04 19:09:31.093 DEBUG [main] [com.zaxxer.hikari.HikariConfig] username........................"defaultuser"
2020-08-04 19:09:31.093 DEBUG [main] [com.zaxxer.hikari.HikariConfig] validationTimeout...............5000
Errors summary:
[main] [com.zaxxer.hikari.HikariDataSource] chapuceros-pool - Starting...
[com.zaxxer.hikari.pool.PoolBase] chapuceros-pool - Failed to create/setup connection: Communications link failure
[com.zaxxer.hikari.pool.HikariPool] chapuceros-pool - Cannot acquire connection from data source
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
Caused by: java.net.SocketException: Broken pipe (Write failed)
答案1
得分: 1
将参数?useSSL=false
添加到jdbcUrl
中解决了我的问题。
英文:
Adding the parameter ?useSSL=false
to the jdbcUrl
solved my problem.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论