Postgresql IllegalStateException:无法连接到数据库。请检查连接和设置

Postgresql IllegalStateException:无法连接到数据库。请检查连接和设置,postgresql,docker,sonarqube,centos7,Postgresql,Docker,Sonarqube,Centos7,CentOS 7 Docker 20.10.5 在我的机器中,运行PostgreSQL 9.5并成功打开我的数据库: localhost:5432/sonar 并成功通过PGAdmin打开数据库 很好 现在在Docker我安装了SonarQube 4.5。并想连接到我的数据库。 我试试这个: sudo docker run -e SONARQUBE_JDBC_USERNAME=sonar -e SONARQUBE_JDBC_PASSWORD=sonar -e SONARQUBE_JDBC_UR

CentOS 7

Docker 20.10.5

在我的机器中,运行PostgreSQL 9.5并成功打开我的数据库:

localhost:5432/sonar
并成功通过PGAdmin打开数据库

很好

现在在Docker我安装了SonarQube 4.5。并想连接到我的数据库。 我试试这个:

sudo docker run -e SONARQUBE_JDBC_USERNAME=sonar -e SONARQUBE_JDBC_PASSWORD=sonar -e SONARQUBE_JDBC_URL=jdbc:postgresql://localhost:5432/sonar sonarqube:4.5.7
但我得到了一个错误:

2021.04.20 11:47:55 INFO  web[o.s.s.p.ServerImpl]  SonarQube Server / 4.5.7 / e2afb0bff1b8be759789d2c1bc9348de6f519f83
2021.04.20 11:47:55 INFO  web[o.s.c.p.Database]  Create JDBC datasource for jdbc:postgresql://localhost:5432/sonar
2021.04.20 11:47:55 ERROR web[o.a.c.c.C.[.[.[/]]  Exception sending context initialized event to listener instance of class org.sonar.server.platform.PlatformServletContextListener
java.lang.IllegalStateException: Can not connect to database. Please check connectivity and settings (see the properties prefixed by 'sonar.jdbc.').
    at org.sonar.core.persistence.DefaultDatabase.checkConnection(DefaultDatabase.java:115) ~[sonar-core-4.5.7.jar:na]
    at org.sonar.core.persistence.DefaultDatabase.start(DefaultDatabase.java:73) ~[sonar-core-4.5.7.jar:na]

这回答了你的问题吗@maio290是的,这是帮助。谢谢