Grails无法连接到数据源,但psql可以吗?

3

Grails 定义:

development {
   dataSource {
     driverClassName = "org.postgresql.Driver"
     dialect = org.hibernate.dialect.PostgreSQLDialect
     pooled = false
     jndiName = null
     url = "jdbc:postgresql://10.197.6.214:5432/mydatabase"
     dbCreate = "create-drop"
     username = "myusername"
     password = "password"
   }
}

可以连接的psql语句:
psql -h 10.197.6.214 -d mydatabase -U myusername

pg_hba.conf文件:

# IPv4 local connections:
host    all         all         0.0.0.0/0          trust
# IPv6 local connections:
host    all         all         ::1/128               md5

postgresql.conf

listen_addresses = '*'
port=5432

这怎么可能发生呢?

更多信息: 看起来如果我从运行数据库的计算机启动grails,启动就可以正常工作,但如果我从另一台计算机尝试,则启动会失败,尽管psql连接没有问题。


你能否从CLI连接到应用服务器机器? - hvgotcodes
返回的信息中没有关于故障的任何信息? - hvgotcodes
只是一个通用的“连接被拒绝”。 - Stefan Kendall
奇怪,一些基本的东西肯定有问题。数据库机器的日志中是否有关于为什么拒绝连接的信息,包括数据库和服务器日志? - hvgotcodes
Caused by: 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 org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is acceptaing TCP/IP connections. - Stefan Kendall
显示剩余2条评论
1个回答

2

看起来 DataSources.groovy 的定义有一个错误条目,这导致了堆栈跟踪底部的主连接失败。一直追溯到顶部,我发现有一个错误的次要数据源定义。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接