1.建立jiwuyf数据库,加入esfpicture1-100个分表,加入esfidfactory主键生成器表
2.jboss下的mysql-ds.xml中加入数据源配置
<local-tx-datasource>
<jndi-name>jiwuyf_slaves_db</jndi-name>
<connection-url>jdbc:mysql://192.168.1.253:3306/jiwuyf?useUnicode=true&characterEncoding=UTF-8&SelectMethod=Cursor;</connection-url>
<driver-class>org.gjt.mm.mysql.Driver</driver-class>
<user-name>jiwudev</user-name>
<password>jiwudev</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
<local-tx-datasource>
<jndi-name>jiwuyf_master_db</jndi-name>
<connection-url>jdbc:mysql://192.168.1.253:3306/jiwuyf?useUnicode=true&characterEncoding=UTF-8&SelectMethod=Cursor;</connection-url>
<driver-class>org.gjt.mm.mysql.Driver</driver-class>
<user-name>jiwudev</user-name>
<password>jiwudev</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
3.测试ejb的persistence.xml中加入
<persistence-unit name="jiwuyf_master" transaction-type="JTA">
<jta-data-source>java:/jiwuyf_master_db</jta-data-source>
<properties>
<property name="hibernate.dialect" value="com.jiwu.core.utils.BlobMySQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
<persistence-unit name="jiwuyf_slaves" transaction-type="JTA">
<jta-data-source>java:/jiwuyf_slaves_db</jta-data-source>
<properties>
<property name="hibernate.dialect" value="com.jiwu.core.utils.BlobMySQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="false" />
</properties>
</persistence-unit>
原文地址:http://www.cnblogs.com/jiwuyf/p/3794096.html