WildFly jdbc 与 Oracle 的连接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31113695/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 02:56:10  来源:igfitidea点击:

WildFly jdbc connection with Oracle

javaoraclejdbcjbosswildfly

提问by Revival

I try to create jdbc connection. I use WildFly Application Server
9.0.0.CR1 and oracle 11g. I put ojdbc14 and created module.xml in the folder C:\wildfly-9.0.0.CR1\modules\com\oracle\ojdbc14\main:

我尝试创建 jdbc 连接。我使用 WildFly 应用服务器
9.0.0.CR1 和 oracle 11g。我把 ojdbc14 并在文件夹 C:\wildfly-9.0.0.CR1\modules\com\oracle\ojdbc14\main 中创建了 module.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<module xmlns=xm lns="urn:jboss:module:1.0"" name="com.oracle.ojdbc14"> 
<resources> 
<resource-root path="ojdbc14.jar"/> 
</resources> 
<dependencies> 
<module name="javax.api"/> 
</dependencies> 
</module>

and inserted to the standalone.xml:

并插入到standalone.xml:

<subsystem xmlns="urn:jboss:domain:datasources:1.0">     
            <datasources>
             <datasource jndi-name="java:jboss/datasources/accounting" pool-name="OracleDS" enabled="true" use-java-context="true"> 
                <connection-url>jdbc:oracle:thin:@cmx-itm-03:1521/COREJAVA</connection-url> 
                <driver-class>oracle.jdbc.OracleDriver</driver-class> 
                <driver>oracle</driver> 
                <security> 
                <user-name>Java_Learning</user-name> 
                <password>Qazxsw123</password> 
                </security> 
            </datasource> 
            <drivers>
                <driver name="oracle" module="com.oracle.ojdbc14"/> 
            </drivers>
            </datasources>
        </subsystem>

So, I got the error when try test connection from console:

所以,当我从控制台尝试测试连接时出现错误:

Unexpected HTTP response: 500

Request
{
    "address" => [
        ("subsystem" => "datasources"),
        ("data-source" => "OracleDS")
    ],
    "operation" => "test-connection-in-pool"
}

Response

Internal Server Error
{
    "outcome" => "failed",
    "failure-description" => "WFLYJCA0040: failed to invoke operation: WFLYJCA0042: failed to match pool. Check JndiName: java:jboss/datasources/accounting",
    "rolled-back" => true
}

I googled it and tried all that I found but still have this error. Please, help me.

我用谷歌搜索并尝试了我找到的所有内容,但仍然出现此错误。请帮我。

采纳答案by carlos gil

This kind of failures are sometimes difficult to fix, because are exceptions from the own server. However check this, check your invalid jndiName in your code.

这种故障有时很难修复,因为是自己服务器的异常。但是检查这个,检查你的代码中无效的 jndiName 。

https://issues.jboss.org/browse/AS7-2199

https://issues.jboss.org/browse/AS7-2199

回答by Revival

  1. I changed ojdbc14.jar to ojdbc6.jar;
  2. Locate module.xml with ojdbc6.jar to wildfly-home\modules\com\oracle\ojdbc\main;
  3. Change max-pool-size from 0 to 70.
  1. 我将 ojdbc14.jar 改为 ojdbc6.jar;
  2. 将带有ojdbc6.jar的module.xml定位到wildfly-home\modules\com\oracle\ojdbc\main;
  3. 将 max-pool-size 从 0 更改为 70。

So, it works

所以,它有效