如何避免java.sql.SQLException - JZ0C0:连接已经关闭。在Wildfly-8.2.0.Final中

时间:2016-03-18 12:47:22

标签: java java-ee database-connection wildfly-8

我在Wildfly-8.2.0.Final应用服务器中部署了一个EAR。经过几个小时的不活动,我收到以下错误:

Caused by: java.sql.SQLException - JZ0C0: Connection is already closed.
   at com.sybase.jdbc4.jdbc.ErrorMessage.raiseError(Unknown Source)
   at com.sybase.jdbc4.jdbc.SybConnection.checkConnection(Unknown Source)
   at com.sybase.jdbc4.jdbc.SybConnection.setAutoCommit(Unknown Source)
   at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.checkTransaction(BaseWrapperManagedConnection.java:893)
   at org.jboss.jca.adapters.jdbc.WrappedConnection.checkTransaction(WrappedConnection.java:1594)
   at org.jboss.jca.adapters.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:398)
   at com.test.it.TestConnection.prepareStatement(TestConnection.java:1045)

请在下面找到 standalone-full-ha.xml 中使用的数据源子系统定义。

<subsystem xmlns="urn:jboss:domain:datasources:2.0">
        <datasources>
            <datasource jta="true" jndi-name="java:/SybaseDB" pool-name="SybaseDB" enabled="true" use-java-context="true" spy="false" use-ccm="true">
                <connection-url>jdbc:sybase:Tds:id_address:port/DBname</connection-url>
                <driver-class>com.sybase.jdbc4.jdbc.SybDriver</driver-class>
                <connection-property name="HOSTNAME">TestHost</connection-property>
                <connection-property name="SQLINITSTRING">set quoted_identifier,forceplan off</connection-property>
                <connection-property name="LANGUAGE">us_english</connection-property>
                <connection-property name="CHARSET">iso_1</connection-property>
                <connection-property name="APPLICATIONNAME">TestApp</connection-property>
                <connection-property name="IS_CLOSED_TEST">select 1</connection-property>
                <connection-property name="PACKETSIZE">1024</connection-property>
                <driver>SybaseDB</driver>
                <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
                <pool>
                    <min-pool-size>5</min-pool-size>
                    <initial-pool-size>5</initial-pool-size>
                    <max-pool-size>200</max-pool-size>
                    <prefill>false</prefill>
                    <use-strict-min>false</use-strict-min>
                    <flush-strategy>FailingConnectionOnly</flush-strategy>
                </pool>
                <security>
                    <security-domain>EncryptDBPassword</security-domain>
                </security>
                <validation>
                    <check-valid-connection-sql>select 1</check-valid-connection-sql>
                    <use-fast-fail>true</use-fast-fail>
                </validation>
                <timeout>
                    <blocking-timeout-millis>15000</blocking-timeout-millis>
                    <idle-timeout-minutes>30</idle-timeout-minutes>
                </timeout>
                <statement>
                    <track-statements>false</track-statements>
                </statement>
            </datasource>
            <drivers>
                <driver name="SybaseDB" module="jdbc.jconn4"/>
            </drivers>
        </datasources>
    </subsystem>

有没有人可以帮助我,我是否缺少数据源定义中的属性,这给了我这个错误。

0 个答案:

没有答案