在JBoss 7(Jeeves DBMS)上防止针对JNDI数据源的Oracle Connection自动提交 [英] Prevent Oracle Connection autocommit for JNDI Datasource on JBoss 7 (Jeeves DBMS)

查看:123
本文介绍了在JBoss 7(Jeeves DBMS)上防止针对JNDI数据源的Oracle Connection自动提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在JBoss 7中使用Oracle JNDI数据源的自动提交设置感到奇怪.

I am currently having an odd situation with the autocommit settings of an Oracle JNDI Datasource in JBoss 7.

大纲

我要部署的应用程序(我可以检查但不能更改)从连接池获取连接,并尝试在某些语句后提交.显然,默认情况下,该连接的自动提交设置为"true",因此会引发异常.

The application I want to deploy, wich I can inspect but not change, obtains connections from the Connection Pool and trys to commit after certain statements. Obviously the connection has autocommit set to 'true' per default and so an exception is raised.

    You cannot commit with autocommit set!

我不能做什么

由于我无法更改应用程序源,因此以下解决方案"不适用:

Due to the fact that I can't change the application source, the following "solution" is not applicable:

    con.setAutoCommit(false);

我尝试过的事情

我浏览了standalone.xml的XML模式,并在数据源定义中发现了两个有希望的元素:

I looked through the XML Schema of the standalone.xml and found two promising elements in the datasource definition:

    <connection-property name="autoCommit">
     false
    </connection-property>

但是这被忽略了.

我还尝试使用具有以下属性的xa数据源:

Further I tried using a xa-datasource with the following property:

    <xa-datasource-property name="autoCommit">
     false
    </xa-datasource-property>

但是autoCommit属性属于连接而不是数据源,因此引发了PropertyNotFound异常.

but the autoCommit property belongs to the connection, not the datasource, so a PropertyNotFound Exception is raised.

我的问题

如何在JBoss7下的JNDI数据源中将Autocommit设置为false,我会丢失什么吗?

How can I set Autocommit to false in a JNDI Datasource under JBoss7 and am I missing something?

我的定义

<datasource jta="false" jndi-name="java:/*****" pool-name="*****" enabled="true">
    <connection-url>jdbc:oracle:thin:@****:****:****</connection-url>
    <connection-property name="autoCommit">
        false
    </connection-property>
    <driver>oracle.jdbc</driver>
    <pool>
        <min-pool-size>10</min-pool-size>
        <max-pool-size>100</max-pool-size>
        <prefill>true</prefill>
        <use-strict-min>false</use-strict-min>
        <flush-strategy>FailingConnectionOnly</flush-strategy>
    </pool>
        <security>
        <user-name>*****</user-name>
        <password>*****</password>
    </security>
    <timeout>
        <blocking-timeout-millis>5000</blocking-timeout-millis>
        <idle-timeout-minutes>1</idle-timeout-minutes>
    </timeout>
</datasource>

更新

代码段:

      public AccessManager(jeeves.resources.dbms.Dbms dbms, SettingManager sm)
        throws SQLException
      {
        List operList = dbms.select("SELECT * FROM Operations").getChildren();          
      }

更新2

我想部署的应用程序是Geonetwork CSW 2.9.0,以防万一有人有经验.我必须配置一个JNDI数据源,因为空间索引仅发生在容器管理的连接上.

The Application I want to deploy is the Geonetwork CSW 2.9.0, just in case someone has experience with this. I have to configure a JNDI datasource because the spatial indexing only happens on container managed connections.

更新3

Stacktrace:

Stacktrace:

    15:52:18,203 ERROR [jeeves.engine] (MSC service thread 1-4) Raised exception while starting appl handler. Skipped.
    15:52:18,205 ERROR [jeeves.engine] (MSC service thread 1-4)    Handler   : org.fao.geonet.Geonetwork
    15:52:18,206 ERROR [jeeves.engine] (MSC service thread 1-4)    Exception : java.sql.SQLException: You cannot commit with autocommit set!
    15:52:18,210 ERROR [jeeves.engine] (MSC service thread 1-4)    Message   : You cannot commit with autocommit set!
    15:52:18,213 ERROR [jeeves.engine] (MSC service thread 1-4)    Stack     : java.sql.SQLException: You cannot commit with autocommit set!
            at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManagedConnection.java:984)
            at org.jboss.jca.adapters.jdbc.WrappedConnection.commit(WrappedConnection.java:757)
            at jeeves.resources.dbms.Dbms.commit(Dbms.java:150)
            at jeeves.resources.dbms.AbstractDbmsPool.close(AbstractDbmsPool.java:158)
            at jeeves.server.resources.ResourceManager.release(ResourceManager.java:302)
            at jeeves.server.resources.ResourceManager.close(ResourceManager.java:270)
            at jeeves.server.JeevesEngine.initAppHandler(JeevesEngine.java:556)
            at jeeves.server.JeevesEngine.init(JeevesEngine.java:182)
            at jeeves.server.sources.http.JeevesServlet.init(JeevesServlet.java:87)
            at javax.servlet.GenericServlet.init(GenericServlet.java:242)
            at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202)
            at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102)
            at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3655)
            at org.apache.catalina.core.StandardContext.start(StandardContext.java:3873)
            at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90)
            at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
            at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
            at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
            at java.lang.Thread.run(Thread.java:662)

更新4

仅意识到Jeeves DBMS是围绕JNDI数据源的简单包装,它可以像使用普通JDBC的任何人一样获取连接.所以我又回到了开始.

Just realized that the Jeeves DBMS is a simple wrapper around the JNDI Datasource that obtains connections just like anyone would do with plain JDBC. So I am back at the beginning.

推荐答案

感谢给我指导,找到了一个非常适合我的解决方案(更正:解决方法).我对原始数据源进行了包装,覆盖了getConnection()方法,并将其绑定到新的JNDI名称下.这样,我可以完全控制数据源,而不会丢失容器的任何功能.

Thanks for giving me directions, found a solution (Correction: Workaround) that suits me well. I made a wrapper around the original datasource, overrid the getConnection() Method and bound it under a new JNDI Name. This way I have full control over the datasource without losing any functionality from the container.

这篇关于在JBoss 7(Jeeves DBMS)上防止针对JNDI数据源的Oracle Connection自动提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆