Could not open JDBC Connection for transaction

org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is 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.)
Caused by:
org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communications link failure

在linux系统下部署项目,启动的时候就报这个错,在网上看了很多资料,有说hosts问题,有说配置文件问题,还有说连接池有问题,看了这么多也不知道改什么,希望大神能够指点指点。

检查连接字符串,你的数据库的配置,比如是否开启防火墙端口例外,用户账户和权限,网络是否连通等。

你使用的jdbc还是jndi的方式,如果是jdbc的话,需要修改连接的url的