如何使 ha-jdbc 数据源工作
我有一个 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 配置访问 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:预期“集群”结束标记,找到“数据源”开始标记(第 19 行,第 11 列)
任何人都可以解释解决方案吗?
i have a ha-jdbc xml where i have this configuration:
<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>
i am accessing ha-jdbc using jpa config:
<?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>
when i run maven i get the following error:
org.jibx.runtime.JiBXException: Expected "cluster" end tag, found "datasource" start tag (line 19, col 11)
could anyone explain what can be the solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论