FYI/followup,
On Sat, Nov 2, 2013 at 9:49 AM, Howard W. Smith, Jr. <[email protected]
> wrote:
> I'm trying to use HA-JDBC[1] with TomEE to have a cluster of at least 2
> databases.
I had to do the following to ensure tomee would create the ha-jdbc resource:
1. add the following java option
-Dha-jdbc.configuration=file:/apache-tomee-plus-1.6.0-SNAPSHOT/lib/ha-jdbc-cluster.xml
2. tomee.xml contains the following
<!--
# create/reference embedded derby driver at startup,
# so the driver can be referenced when ha-jdbc resource is created
-->
<Resource id="jdbc/startup" type="javax.sql.DataSource">
JdbcDriver org.apache.derby.jdbc.EmbeddedDriver
JdbcUrl jdbc:derby:C:/javadb/databases/startup;create=true
UserName ....
Password ....
JtaManaged false
jmxEnabled false
LogSql false
ignoreDefaultValues true
</Resource>
<Resource id="jdbc/mcmsJta" type="javax.sql.DataSource">
JdbcDriver net.sf.hajdbc.sql.Driver
JdbcUrl jdbc:ha-jdbc:cluster
UserName ....
Password ....
JtaManaged true
jmxEnabled false
LogSql false
InitialSize 10
MaxActive 100
MaxIdle 30
MaxWait 10000
minIdle 10
suspectTimeout 60
removeAbandoned true
removeAbandonedTimeout 180
timeBetweenEvictionRunsMillis 30000
jdbcInterceptors=StatementCache(max=128)
</Resource>
3. ha-jdbc-cluster.xml (located in tomee/lib)
<?xml version="1.0" encoding="UTF-8"?>
<ha-jdbc xmlns="urn:ha-jdbc:cluster:2.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://ha-jdbc.github.io/xsd/ha-jdbc-2.1.0-beta-4.xsd">
<sync id="full">
<property name="fetchSize">1000</property>
</sync>
<sync id="diff">
<property name="fetchSize">1000</property>
<property name="versionPattern">version</property>
</sync>
<state id="simple"/>
<cluster dialect="derby" balancer="simple" default-sync="full"
meta-data-cache="lazy" transaction-mode="parallel">
<database id="db1" weight="1"
location="jdbc:derby:c:/javadb/databases/mcms;create=true">
<user>....</user>
<password>....</password>
<property name="databaseName">mcms</property>
<property
name="driver">org.apache.derby.jdbc.EmbeddedDriver</property>
</database>
<database id="db2" weight="2"
location="jdbc:derby:c:/javadb/databases/mcmsdev;create=true">
<user>....</user>
<password>....</password>
<property name="databaseName">mcms</property>
<property
name="driver">org.apache.derby.jdbc.EmbeddedDriver</property>
</database>
</cluster>
</ha-jdbc>
4. drop ha-jdbc-2.1.0-beta-4.jar (and ha-jdbc-2.1.0-beta-4.xsd) in tomee/lib
SQL SELECTs are working as expected, but i'm seeking advice (in the ha-jdbc
forum) on how to configure ha-jdbc for multiple table-and-row INSERTs. :)