jboss 4.0.4
在$jboss_home\docs\examples\jca下可以找到各种例子*-ds.xml,我配置的是informix,所以拿下informix,copy到$jboss_home\server\default\deploy下,再修改
<?xml version="1.0" encoding="UTF-8"?>
<!-- ===================================================================== -->
<!-- -->
<!-- JBoss Server Configuration -->
<!-- -->
<!-- ===================================================================== -->
<!-- $Id: informix-ds.xml,v 1.3.2.1 2004/12/01 11:44:11 schrouf Exp $ -->
<datasources>
<local-tx-datasource>
<jndi-name>CORP_DS</jndi-name>
<use-java-context>false</use-java-context>
<connection-url>jdbc:informix-sqli://localhost:2021/test:informixserver=informix</connection-url>
<driver-class>com.informix.jdbc.IfxDriver</driver-class>
<user-name>informix</user-name>
<password>123456</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.InformixExceptionSorter</exception-sorter-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
<check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
-->
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
</local-tx-datasource>
</datasources>
jndi-name就是jndi的名字,
connection-url就是用java里的getConnection(url)里的url,
driver-class就是jdbc驱动类名
user-name\password是数据库的用户\密码
exception-sorter-class-name不知道是什么,用的是例子的
如果要用jboss jvm外的jvm调用jndi的话一定要加上<use-java-context>false<user-java-context>,否则会找不到jndi的