如何使ha-jdbc数据源工作

时间:2011-02-08 09:30:58

标签: java hibernate jpa datasource high-availability

我有一个ha-jdbc xml,我有这个配置:

<ha-jdbc>
    <sync id="diff" class="net.sf.hajdbc.sync.DifferentialSynchronizationStrategy">
      <property name="fetchSize">1000</property>
      <property name="maxBatchSize">100</property>
    </sync>
    <sync id="full" class="net.sf.hajdbc.sync.FullSynchronizationStrategy">
      <property name="fetchSize">1000</property>
      <property name="maxBatchSize">100</property>
    </sync>
  <cluster balancer="load" 
       dialect="net.sf.hajdbc.dialect.MySQLDialect" 
       default-sync="full" 
       transaction-mode="parallel" 
       auto-activate-schedule="0 * * ? * *" 
       failure-detect-schedule="0 * * ? * *"
       meta-data-cache="none">
         <database id="database1">
               <driver>****</driver>
               <url>****</url>
               <user>****</user>
               <password>****</password>
         </database>
         <database id="database2">
               <driver>****</driver>
               <url>****</url>
               <user>****</user>
               <password>****</password>
         </database>
    </cluster>
  </ha-jdbc>

我正在使用jpa config访问ha-jdbc:

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
                             http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
         version="1.0">
<persistence-unit name="app_data" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <properties>
        <property name="hibernate.connection.driver_class" value="net.sf.hajdbc.sql.Driver" />
        <!--property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/-->
        <property name="hibernate.connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider" />
        <property name="hibernate.connection.url" value="jdbc:ha-jdbc:cluster1" />
        <property name="hibernate.connection.username" value="****" />
        <property name="hibernate.connection.password" value="****" />
        <property name="hibernate.show_sql" value="true" />
        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
        <!--property name="hibernate.hbm2ddl.auto" value="update" /-->

        <property name="hibernate.c3p0.min_size" value="5" />
        <property name="hibernate.c3p0.max_size" value="20" />
        <property name="hibernate.c3p0.timeout" value="1800" />
        <property name="hibernate.c3p0.max_statements" value="50" />
        <property name="hibernate.c3p0.idle_test_period" value="3000" />
    </properties>
</persistence-unit>

当我运行maven时,我收到以下错误:

org.jibx.runtime.JiBXException:预期的“cluster”结束标记,找到“datasource”开始标记(第19行,第11行)

任何人都可以解释什么是解决方案?

0 个答案:

没有答案