环境:JBoss EAP 6.4
1. 部署 DataSource (Derby)
1.1 部署 JDBC jar 方式
(1)cd /Users/maping/Apache/db-derby/bin
启动 ./startNetworkServer
停止 ./stopNetworkServer
进入SQL交互 ./ij
ij> Connect 'jdbc:derby:demoDB;create=true;user=demo;password=demo';
ij> CREATE TABLE test_table(id int primary key, name varchar(20));
ij> INSERT INTO test_table VALUES(1,'China');
ij> SELECT * FROM test_table;
ij> Connect 'jdbc:derby:demoDB;user=demo;password=demo';
ij> SELECT * FROM test_table;
(2)SQuirrel SQL 连接地址:jdbc:derby://localhost:1527/demoDB
注意,使用SQuirrel SQL客户端连接时,要断开ij客户端,否则连不上,原因不明。
(3)./standalone.sh -Djboss.server.base.dir=/Users/maping/Redhat/eap/demo/myeap -Djboss.socket.binding.port-offset=10000
(4)部署 db-derby 的JDBC jar:derbyclient.jar
(5)创建并配置 DataSource,name:DerbyDSPool,JNDI:java:jboss/datasources/DerbyDS
(6)http://localhost:19990/ 部署 dstest.war
(7)http://localhost:18080/dstest
1.2 以module方式部署 JDBC jar
(1)(2)步 与 部署JDBC jar 方式相同
(3)在 [jboss_home]/modules 目录下,创建目录:mkdir -p org/apache/derby/main,在 main 目录下创建 module.xml,内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.apache.derby">
<resources>
<resource-root path="derbyclient.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
(4)复制 derbyclient.jar 到main目录下
(5)cp standalone.xml standalone-derby.xml
(6)vim standalone-derby.xml,修改datasource部分
<subsystem xmlns="urn:jboss:domain:datasources:1.2">
<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/DemoDataSource" pool-name=“DemoDataSource" enabled="true" use-ccm="false">
<connection-url>jdbc:derby://localhost:1527/demoDB</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>
(7)./standalone.sh -Djboss.server.base.dir=/Users/maping/Redhat/eap/demo/myeap -c standalone-derby.xml -Djboss.socket.binding.port-offset=10000
(8)http://localhost:19990/ 部署 dstest.war
(9)http://localhost:18080/dstest
1. 部署 DataSource (Derby)
1.1 部署 JDBC jar 方式
(1)cd /Users/maping/Apache/db-derby/bin
启动 ./startNetworkServer
停止 ./stopNetworkServer
进入SQL交互 ./ij
ij> Connect 'jdbc:derby:demoDB;create=true;user=demo;password=demo';
ij> CREATE TABLE test_table(id int primary key, name varchar(20));
ij> INSERT INTO test_table VALUES(1,'China');
ij> SELECT * FROM test_table;
ij> Connect 'jdbc:derby:demoDB;user=demo;password=demo';
ij> SELECT * FROM test_table;
(2)SQuirrel SQL 连接地址:jdbc:derby://localhost:1527/demoDB
注意,使用SQuirrel SQL客户端连接时,要断开ij客户端,否则连不上,原因不明。
(3)./standalone.sh -Djboss.server.base.dir=/Users/maping/Redhat/eap/demo/myeap -Djboss.socket.binding.port-offset=10000
(4)部署 db-derby 的JDBC jar:derbyclient.jar
(5)创建并配置 DataSource,name:DerbyDSPool,JNDI:java:jboss/datasources/DerbyDS
(6)http://localhost:19990/ 部署 dstest.war
(7)http://localhost:18080/dstest
1.2 以module方式部署 JDBC jar
(1)(2)步 与 部署JDBC jar 方式相同
(3)在 [jboss_home]/modules 目录下,创建目录:mkdir -p org/apache/derby/main,在 main 目录下创建 module.xml,内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.apache.derby">
<resources>
<resource-root path="derbyclient.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
(4)复制 derbyclient.jar 到main目录下
(5)cp standalone.xml standalone-derby.xml
(6)vim standalone-derby.xml,修改datasource部分
<subsystem xmlns="urn:jboss:domain:datasources:1.2">
<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/DemoDataSource" pool-name=“DemoDataSource" enabled="true" use-ccm="false">
<connection-url>jdbc:derby://localhost:1527/demoDB</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>
(7)./standalone.sh -Djboss.server.base.dir=/Users/maping/Redhat/eap/demo/myeap -c standalone-derby.xml -Djboss.socket.binding.port-offset=10000
(8)http://localhost:19990/ 部署 dstest.war
(9)http://localhost:18080/dstest
没有评论:
发表评论