gpt4 book ai didi

java - 在 Bluemix 中启动应用程序时无法创建 PoolableConnectionFactory 错误

转载 作者:行者123 更新时间:2023-11-30 03:28:48 26 4
gpt4 key购买 nike

当我将 Java 应用程序部署到 IBM Bluemix 后,由于以下错误,它无法创建初始数据库连接:

Building new Hibernate SessionFactory 2015-04-11 14:24:04 [main] ERROR o.h.util.JDBCExceptionReporter - Cannot create PoolableConnectionFactory (Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.)

我尝试将“hibernate.current_session_context_class”设置为“thread”(这解决了我将同一应用程序部署到 Google Application Engine 时的问题),但这对 Websphere Liberty Profile 没有帮助:

<prop key="hibernate.current_session_context_class" >
thread
</prop>

有什么想法吗?

更新 1 --- 这是真正的根本原因。 Bluemix 提供 ClearDB MySQL 服务,但其管道无法连接到它:(

Building new Hibernate SessionFactory 2015-04-11 15:04:49 [main] ERROR o.h.util.JDBCExceptionReporter - Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

更新 2 --- 如果尝试从管道机器进行连接,即使实验 MySQL 数据库也受到限制:

o.h.util.JDBCExceptionReporter - Cannot create PoolableConnectionFactory (Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.) org.hibernate.exception.GenericJDBCException: Cannot open connection at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140) at org.hibe at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75) Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.) at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549) at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388) at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044) at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446) ... 40 more Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

如果您有任何想法,请告诉我。

最佳答案

啊好吧。之所以会发生这种情况,是因为 Liberty buildpack 在部署到 Bluemix 期间会自动连接 JDBC 连接。对于单元测试,您需要向您的应用提供此连接信息。

关于java - 在 Bluemix 中启动应用程序时无法创建 PoolableConnectionFactory 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29579135/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com