Spring引导与非本地数据库的连接

时间:2017-05-27 08:12:12

标签: spring database-connection

i create a spring boot project with a local database and the connection work correctly :

# DATASOURCE setting:
spring.datasource.url=jdbc:mysql://localhost:3306/t_anomalies
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driverClassName=com.mysql.jdbc.Driver
# JPA :
spring.jpa.database=MYSQL
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.naming.strategy=-
strategy=strategy=org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect

但现在我将我的数据库放在Web服务器中 我更改了所有配置(主机,root,密码)但我总是收到此消息“通信链接失败”

# DATASOURCE setting:
spring.datasource.url=jdbc:mysql://newhost3:3306/t_anomalies
spring.datasource.username=newroot
spring.datasource.password=password
spring.datasource.driverClassName=com.mysql.jdbc.Driver
# JPA :
spring.jpa.database=MYSQL
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.naming.strategy=-
strategy=strategy=org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect

1 个答案:

答案 0 :(得分:0)

你在' newhost3'中使用了什么?主机名。首先验证与该主机的连接。