Wildfly 10不断失去与Postgres数据源的连接

时间:2017-12-04 10:27:30

标签: java database postgresql jboss wildfly

我已成功在Wildfly 10.1 final上设置Postgres数据源。使用数据源的应用程序仍处于开发阶段,因此尚未真正使用。

Wildfly和postgres都在自己的VM中运行,但是在同一台主机上运行。

大约每天一次,连接显然会丢失,只有重新启动野生蝇就足以重建它。

在wildfly的server.log中,我找不到与我的数据源相关的任何消息。以下是standalone.xml的数据源配置

           <datasource jta="true" jndi-name="java:/JMPostgres" pool-name="PostgresDS" enabled="true" use-ccm="false">
                <connection-url>jdbc:postgresql://10.66.1.102:5432/jm10</connection-url>
                <driver-class>org.postgresql.Driver</driver-class>
                <driver>postgresql-42.1.4.jar</driver>
                <pool>
                    <min-pool-size>5</min-pool-size>
                    <initial-pool-size>5</initial-pool-size>
                    <max-pool-size>50</max-pool-size>
                    <prefill>true</prefill>
                </pool>
                <security>
                    <user-name>jm10</user-name>
                    <password>Ba4aeng$eeth0iog.ee2zohB</password>
                </security>
                <validation>
                    <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"/>
                    <check-valid-connection-sql>SELECT 1 FROM DUAL;</check-valid-connection-sql>
                    <validate-on-match>true</validate-on-match>
                    <background-validation>true</background-validation>
                    <background-validation-millis>60000</background-validation-millis>
                    <stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.StaleConnectionChecker"/>
                    <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"/>
                </validation>
                <timeout>
                    <allocation-retry>5</allocation-retry>
                    <allocation-retry-wait-millis>10000</allocation-retry-wait-millis>
                </timeout>
            </datasource>

1 个答案:

答案 0 :(得分:1)

我的回复有点晚了,但是您不应该在激活后台验证的情况下使用 validate-on-match = true 。它们是相互排斥的。

失败后如何重新连接到数据库的示例(使用连接验证)是:how to validate Database connection with WildFly

相关问题