資料來源不定時間段後串連中斷(解決方案:串連關閉後設定自啟動,重新自動連接。問題描述如下 ):
資料來源原設定檔如下:(備忘:劃紅線的2行出現衝突)
修改後的資料來源配置如下:(解決不定時間資料庫連接中斷問題)(備忘: 校正代碼的(部分)作用:當資料庫連接斷開後,重新自動連接。 ) <validation> <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/> <check-valid-connection-sql>select 1 from dual</check-valid-connection-sql> //<validate-on-match>false</validate-on-match> <background-validation>true</background-validation> <background-validation-millis>200000</background-validation-millis> <use-fast-fail>false</use-fast-fail> <stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/> <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/> </validation>
(補充知識)工程中wildfly伺服器設定檔的配置 雙物理機資料來源(配置代碼): <connection-url>jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.100.24.30)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=10.100.24.31)(PORT=1521))(LOAD_BALANCE=yes)(FAILOVER=on))(CONNECT_DATA=(SERVICE_NAME=orcl )))</connection-url> 工程中wildfly伺服器設定檔的配置 一個物理機資料來源(配置代碼): < connection-url > jdbc:oracle:thin:@192.168.2.231:1521:orcl </ connection-url > ( 備忘: 部署工程時資料庫部署在多個物理機上防止一個資料庫物理機掛了影響工程,當資料庫部署在多個物理機上時,可以建立一個虛擬機器資料庫用於關聯多個 物理機資料庫,從而在伺服器的資料來源串連設定檔中只需要一個ip串連即可) 整個資料來源配置代碼如下(雙物理機配置 ): <datasources> <datasource jta="true" jndi-name="java:jboss/datasources/OracleDS_UAM" pool-name="OracleDS_UAM" enabled="true" use-java-context="true" use-ccm="true"> <connection-url>jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.100.24.30)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=10.100.24.31)(PORT=1521))(LOAD_BALANCE=yes)(FAILOVER=on))(CONNECT_DATA=(SERVICE_NAME=orcl )))</connection-url> <driver-class>oracle.jdbc.driver.OracleDriver</driver-class> <driver>oracle</driver> <pool> <min-pool-size>10</min-pool-size> <max-pool-size>100</max-pool-size> <prefill>true</prefill> <use-strict-min>false</use-strict-min> <flush-strategy>FailingConnectionOnly</flush-strategy> </pool> <security> <user-name>sdsy</user-name> <password>sdsy1qaz@WSX.</password> </security> <validation> <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/> <check-valid-connection-sql>select 1 from dual</check-valid-connection-sql> <background-validation>true</background-validation> <background-validation-millis>200000</background-validation-millis> <use-fast-fail>false</use-fast-fail> <stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/> <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/> </validation> </datasource> <drivers> <driver name="oracle" module="com.oracle"> <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class> </driver> </drivers> </datasources>