How to configure a HA DataSource in JBoss 7.1 ?
seanchenxi Jan 24, 2012 1:33 PMHello,
We are currnently migrating a JBoss 5 App to JBoss 7.1. But we have a problem with the DataSource Configuration:
can't find the way to configure a HA DataSource (set two urls in connection-url) to treate the database failover case.
In JBoss 5.1, we simply separating the Databases' URL with "|", characters as follows:
<datasources>
<local-tx-datasource>
<jndi-name>MyDatabase</jndi-name>
<use-java-context>false</use-java-context>
<connection-url>
jdbc:sqlserver://SQL_SERVER_ONE:1433;databaseName=MyDB;|jdbc:sqlserver://SQL_SERVER_TWO:1433;databaseNameMyDB</connection-url>
<url-delimiter>|</url-delimiter>
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
<databaseName>MyDB</databaseName>
<user-name>USER_NAME</user-name>
<password>USER_PWD</password>
<check-valid-connection-sql>select COUNT(*) from VERSION
</check-valid-connection-sql>
</local-tx-datasource>
</datasources>
The following is my attempt which does not work in JBoss 7.1 :
<datasource jndi-name="java:/MyDatabase" pool-name="MyPool" enabled="true" use-java-context="true" use-ccm="false">
<connection-url>jdbc:sqlserver://SQL_SERVER_ONE:1433;databaseName=MyDB|jdbc:sqlserver://SQL_SERVER_TWO:1433;databaseName=MyDB</connection-url>
<url-delimiter>|</url-delimiter>
<driver>
sqlserver
</driver>
<security>
<user-name>USER_NAME</user-name>
<password>USER_PWD</password>
</security>
<validation>
<check-valid-connection-sql>
select COUNT(*) from VERSION
</check-valid-connection-sql>
</validation>
</datasource>
<drivers>
<driver name="sqlserver" module="com.microsoft.sqlserver">
<driver-class>
com.microsoft.sqlserver.jdbc.SQLServerDriver
</driver-class>
</driver>
</drivers>
I simply tried to separate the host and servername using "|" characters, just like in JBoss 5. But if I shutdown the first DB, it desn't try to make a new connection with the second DB url...
Can anyone even point me in the right direction? Even an example of an ha xa datasource configuration would help.
Thanks,