公告
财富商城
积分规则
提问
发文
2019-02-15 00:07发布
太酷不给撩
Can anybody provide the steps for creating DataSource in JBoss server(5.0) with Oracle Database..
Thanks in Advance
Here is a link to JBoss that explains it for you.
This example assumes you're using Oracle 10i.
In JBoss 5, create an XML file ending with -ds.xml (although not necessarily -ds, it has to be an XML file). with the following descriptor elements.
-ds.xml
-ds
This is an example to do Local-TX datasource.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE datasources PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN" "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd"> <datasources> <local-tx-datasource> <jndi-name>MyDataSourceName</jndi-name> <driver-class>oracle.jdbc.driver.OracleDriver</driver-class> <connection-url>jdbc:oracle:oci:@(description=(address=(host=youroraclehost)(protocol=tcp)(port=1521))(connect_data=(SERVICE_NAME=yourservicename)))</connection-url> <user-name>myUserName</user-name> <password>myPassword</password> <min-pool-size>20</min-pool-size> <metadata> <type-mapping>Oracle9i</type-mapping> </metadata> </local-tx-datasource> </datasources>
You can have more than 1 <local-tx-datasource> element but <jndi-name> must be unique.
<local-tx-datasource>
<jndi-name>
For XA datasource, see an example here.
The above example is saved in MyDataSourceName-ds.xml.
MyDataSourceName-ds.xml
The XML file must be placed under JBOSS_HOME/server/<default|all>/deploy folder.
JBOSS_HOME/server/<default|all>/deploy
Now, in Java, you will retrieve MyDataSourceName as follows:
MyDataSourceName
InitialContext ctx = new InitialContext(); DataSource ds = (DataSource)ctx.lookup("java:MyDataSourceName"); Connection connection = ds.getConnection();
最多设置5个标签!
Here is a link to JBoss that explains it for you.
This example assumes you're using Oracle 10i.
In JBoss 5, create an XML file ending with
-ds.xml
(although not necessarily-ds
, it has to be an XML file). with the following descriptor elements.This is an example to do Local-TX datasource.
You can have more than 1
<local-tx-datasource>
element but<jndi-name>
must be unique.For XA datasource, see an example here.
The above example is saved in
MyDataSourceName-ds.xml
.The XML file must be placed under
JBOSS_HOME/server/<default|all>/deploy
folder.Now, in Java, you will retrieve
MyDataSourceName
as follows: