2014年7月16日星期三

EAP_007:配置Derby数据源

开发运行环境:JBoss EAP 6.2.0 + Derby 10.10.2.0

1. 在[jboss_home]/modules目录下,创建目录:org/apache/derby/main

2. 在main目录下创建module.xml,内容如下:

<?xml version=“1.0” encoding=“UTF-8”?>
<module xmlns=“urn:jboss:module:1.0” name=“org.apache.derby”>
    <resources>
        <resource-root path=“derbyclient.jar”/>
    </resources>
    <dependencies>
        <module name=“javax.api”/>
        <module name=“javax.transaction.api”/>
    </dependencies>
</module>

3. 修改standalone.xml,其中datasources subsystem部分修改如下:

 <subsystem xmlns=“urn:jboss:domain:datasources:1.1”>
            <datasources>
                <datasource jndi-name=“java:jboss/datasources/ExampleDS” pool-name=“ExampleDS” enabled=“true” use-java-context=“true”>
                    <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
                    <driver>h2</driver>
                    <security>
                        <user-name>sa</user-name>
                        <password>sa</password>
                    </security>
                </datasource>
                <datasource jndi-name=“java:jboss/datasources/DerbyDSDemo” pool-name=“DerbyDSDemoPool” enabled=“true” use-ccm=“false”>
                    <connection-url>jdbc:derby://localhost:1527/demoDB;create=true</connection-url>
                    <driver>org.apache.derby</driver>
                    <security>
                        <user-name>demo</user-name>
                        <password>demo</password>
                    </security>
                    <validation>
                        <validate-on-match>false</validate-on-match>
                        <background-validation>false</background-validation>
                    </validation>
                    <statement>
                        <share-prepared-statements>false</share-prepared-statements>
                    </statement>
                </datasource>
                <drivers>
                    <driver name=“h2” module=“com.h2database.h2”>
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                    <driver name=“org.apache.derby” module=“org.apache.derby”>
                        <xa-datasource-class>org.apache.derby.jdbc.ClientXADataSource</xa-datasource-class>
                    </driver>
                </drivers>
            </datasources>
        </subsystem>

4. 复制derbyclient.jar到main目录下

参考文献:
1. http://www.hameister.org/JBoss_DatasourceDerby.html
2. http://db.apache.org/derby/integrate/SQuirreL_Derby.html
3. http://www.squirrelsql.org/index.php#installation

没有评论: