gpt4 book ai didi

java - AWS RDS 连接数据库错误 : com. mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

转载 作者:行者123 更新时间:2023-11-30 21:44:35 26 4
gpt4 key购买 nike

我正在尝试在 AWS linux 实例上部署我的 springboot 应用程序,但是我不断收到以下错误:

2018-04-24 18:15:27.777  INFO 24020 --- [ost-startStop-1] 

o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2018-04-24 18:15:28.771 ERROR 24020 --- [main] o.a.tomcat.jdbc.pool.ConnectionPool: Unable to create initial connections of pool.

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 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 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_161]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_161]

...

2018-04-24 16:58:57.522 WARN 23780 --- [main] o.s.b.a.orm.jpa.DatabaseLookup : Unable to determine jdbc url from datasource

org.springframework.jdbc.support.MetaDataAccessException: Could not get Connection for extracting meta data; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException:
Could not get JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

这就是我创建 applications.properties 文件的方式:

#database config
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://****-west-1.rds.amazonaws.com:3306/DevManagementDB
spring.datasource.username=root
spring.datasource.password=mypassword
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.ddl-auto=update

奇怪的是,当我在本地机器上运行应用程序时,我可以从这个 springboot 应用程序连接到我的 RDS 数据库。一旦我尝试将应用程序部署到 AWS 上的 linux 实例,它就会失败,并且出现上述错误。

最佳答案

如果您的数据库是 RDS 实例,请确保访问数据库的设备的公共(public) IP 地址包含在 RDS 实例的安全组中。还要确保公共(public) IP 地址包含在相应 VPC 安全组的入站 channel 中。

关于java - AWS RDS 连接数据库错误 : com. mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50008728/

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