新文章移至
http://cffile.sinaapp.com/?p=281.New--Enterprise Application Project
2.从jboss\docs\examples\jca复制一个数据源配置 如mysql-ds.xml 到jboss5\server\default\deploy下3.把mysql-connector-java-5.0.8-bin.jar拷到server\default\lib下
4.编辑代码
5.部署 注意要部署myejb工程 删server\default\deploy\myejb.ear\myejbWeb.war\WEB-INF\classes\META-INF\persistence.xml
否则会报PersistenceUnitMetaData ... Component already registered.
附:mysql-ds.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: mysql-ds.xml 41017 2006-02-07 14:26:14Z acoliver $ -->
<!-- Datasource config for MySQL using 3.0.9 available from:
http://www.mysql.com/downloads/api-jdbc-stable.html
-->
<datasources>
<local-tx-datasource>
<jndi-name>MySqlDS</jndi-name>
<connection-url>jdbc:mysql://127.0.0.1:3306/test</connection-url>
<use-java-context>false</use-java-context>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password>000000</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<!-- should only be used on drivers after 3.22.1 with "ping" support
<valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
-->
<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
-->
<!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers
<check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
-->
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>