Postgres数据源定义 - 连接被拒绝

时间:2016-04-09 14:51:51

标签: java postgresql jdbc datasource

我正在尝试设置一个快速数据源,用于集成测试,因此不是在应用服务器上配置它 - Wildfly 10 - 我更喜欢动态部署它。 / p>

这就是我配置它的方式:

@DataSourceDefinitions({
    @DataSourceDefinition(
            name = "java:/datasources/testdb",
            className = "org.postgresql.xa.PGXADataSource",
            user = "testdb",
            password = "testdb",
            serverName = "localhost",
            portNumber = 5432,
            databaseName = "testdb",
            minPoolSize = 10,
            maxPoolSize = 50)
})
public class DatasourceDefinitions {}

我已尝试使用localhost127.0.0.1并使用参数url代替三serverNameport和{{1} },但我总是遇到databaseName错误

Connection Refused

我已经检查了Caused by: java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at java.net.Socket.connect(Socket.java:538) at java.net.Socket.<init>(Socket.java:434) at java.net.Socket.<init>(Socket.java:211) at org.postgresql.core.PGStream.<init>(PGStream.java:62) at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:76) ... 41 more user,如果我尝试使用password登录,它们的工作正常。

这是Postgres配置:

pgAdmin

我也启用了这行

# Database administrative login by Unix domain socket
local   all             postgres                                peer

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                peer
#host    replication     postgres        127.0.0.1/32            md5

在配置文件listen_addresses = 'localhost' # what IP address(es) to listen on;

有谁能告诉我我错过了什么和/或做错了什么?

0 个答案:

没有答案