简体   繁体   English

无法在 Jboss AS 7 上定义 oracle 数据源

[英]Unable to define oracle datasource on Jboss AS 7

I'm using Jboss AS 7.1.1.final and I'm trying to add an oracle Datasource:我正在使用 Jboss AS 7.1.1.final 并尝试添加 oracle 数据源:

<datasource jndi-name="java:jboss/datasources/DefaultDS" 
            pool-name="DefaultDS" 
            enabled="true" 
            use-java-context="true">
    <connection-url>jdbc:oracle:oci@TNS_NAME</connection-url>
    <driver>oracle</driver>
    <security>
        <user-name>username</user-name>
        <password>pwd</password>
    </security>
</datasource>

And the driver:和司机:

<driver name="oracle" module="com.oracle.ojdbc">
   <xa-datasource-class>oracle.jdbc.OracleDriver</xa-datasource-class>
</driver>

But when I start the server I get:但是当我启动服务器时,我得到:

JBAS014775:    New missing/unsatisfied dependencies:
  service jboss.jdbc-driver.oracle (missing) dependents: [service jboss.data-source.java:jboss/datasources/DefaultDS] 

I have a module under modules/com/oracle/ojdbc/main:我在 modules/com/oracle/ojdbc/main 下有一个模块:

<module xmlns="urn:jboss:module:1.0" name="com.Oracle.ojdbc">
    <resources>
        <resource-root path="ojdbc6.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
    </dependencies>
</module>

and of course the jar is there.当然还有 jar。

Can someone please tell me what am I doing wrong here?有人可以告诉我我在这里做错了什么吗?

Add this to define driver: for xa datasource添加这个来定义驱动程序:for xa datasource

<driver name="oracleDriver" module="com.oracle.ojdbc">
         <driver-class>oracle.jdbc.OracleDriver</driver-class>
         <xa-datasource-class>oracle.jdbc.xa.OracleXADataSource</xa-datasource-class>
</driver>

for non-xa-------对于非 xa------

<driver name="oracleDriver" module="com.oracle.ojdbc">
         <driver-class>oracle.jdbc.OracleDriver</driver-class>
    </driver>

Got the answer:得到答案:

In the drivers section, I defined the driver as sitting in module "com.oracle.ojdbc" but the module itself is actually defined with capital 'O' in ' O racle' so it should be "com.Oracle.ojdbc"在驱动程序部分,我将驱动程序定义为位于模块"com.oracle.ojdbc"中,但模块本身实际上是在“ O racle”中用大写字母“ O”定义的,因此它应该是"com.Oracle.ojdbc"

Add this to define driver: for xa datasource添加这个来定义驱动程序:for xa datasource

<driver name="oracleDriver" module="com.oracle.ojdbc">
         <driver-class>oracle.jdbc.OracleDriver</driver-class>
         <xa-datasource-class>oracle.jdbc.xa.OracleXADataSource

for non-xa-------对于非 xa------

<driver name="oracleDriver" module="com.oracle.ojdbc">
         <driver-class>oracle.jdbc.OracleDriver</driver-class>
    </driver>

Path for the ojdbc jar in my case was: D:\ProgramFiles\JBoss6.4\modules\com\oracle\jdbc7\main where D:\ProgramFiles\JBoss6.4\ is the JBOSS HOME directory.在我的例子中,ojdbc jar 的路径是: D:\ProgramFiles\JBoss6.4\modules\com\oracle\jdbc7\main其中 D:\ProgramFiles\JBoss6.4\ 是 JBOSS HOME 目录。

in the main folder, need to have following files.在主文件夹中,需要有以下文件。

ojdbc7.jar
module.xml

Entry for Module would look like below:模块条目如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.oracle.jdbc7">
<properties>
        <property name="jboss.api" value="unsupported"/>
    </properties>
 <resources>
 <resource-root path="ojdbc7.jar"/>
 </resources>
 <dependencies>
 <module name="javax.api"/>
 <module name="javax.transaction.api"/>
 <module name="javax.servlet.api" optional="true"/>
 </dependencies>
</module>

You can define datasource from admin interface, find good tutorial below您可以从管理界面定义数据源,在下面找到很好的教程

http://middlewaremagic.com/jboss/?p=350 http://middlewaremagic.com/jboss/?p=350

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM