简体   繁体   English

无法将autoAutoCommit设置为true-Weblogic 12-SQL Server

[英]Failed to setAutoCommit to true - Weblogic 12 - SQL Server

We have an application using a Weblogic pooled non-XA SQL Server JDBC driver. 我们有一个使用Weblogic池化的非XA SQL Server JDBC驱动程序的应用程序。 Here is the flow of what is causing the issue. 这是引起问题的原因的流程。

Get connection from datasource. 从数据源获取连接。

Set auto commit to false. 将自动提交设置为false。

Create CallableStatement. 创建CallableStatement。

Set parameters. 设置参数。

Call executeUpdate. 调用executeUpdate。

  • Inside stored proc call, the database raises an error with SET XACT_ABORT as ON 在存储的proc调用内部,数据库使用SET XACT_ABORT设置为ON引发错误

Application sees error code in out param of CallableStatement. 应用程序在CallableStatement的参数外看到错误代码。

Closes CallableStatement 关闭CallableStatement

Calls rollback on the connection. 调用连接上的回滚。

Exception is thrown: 抛出异常:

2013-Oct-17 16:45:20.500 EDT||XXXXXXX|asyncDelivery9|XXX|XXX|XXXX-a3436e48-1672-4a26-88c0-50b9954f6a42|ERROR|XXXXX|rollBack|The server failed to resume the transaction. 2013年10月17日16:45:20.500 EDT || XXXXXXX | asyncDelivery9 | XXX | XXX | XXXX-a3436e48-1672-4a26-88c0-50b9954f6a42 | ERROR | XXXXX | rollBack |服务器无法恢复交易。 Desc:4200000012. 说明:4200000012。 com.microsoft.sqlserver.jdbc.SQLServerException: The server failed to resume the transaction. com.microsoft.sqlserver.jdbc.SQLServerException:服务器无法恢复事务。 Desc:4200000012. 说明:4200000012。 at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216) ~[sqljdbc4.jar:na] at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:254) ~[sqljdbc4.jar:na] at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:84) ~[sqljdbc4.jar:na] at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:39) ~[sqljdbc4.jar:na] at com.microsoft.sqlserver.jdbc.SQLServerConnection$1ConnectionCommand.doExecute(SQLServerConnection.java:1756) ~[sqljdbc4.jar:na] at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696) ~[sqljdbc4.jar:na] at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715) ~[sqljdbc4.jar:na] at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectionCommand(SQLServerConnection.java:1761) ~[sqljdbc4.jar:na] at com.microsoft.sqlserver.jdbc.SQLServerConnection.rollback(SQLServerConnection.java:1964) ~[sqljdbc4.jar:na] at weblogic.jdbc.wrapper.PoolConnection_com_m 在com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:254)〜[sqljdbc4.com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)〜[sqljdbc4.jar:na] jar:na]在com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:84)〜[sqljdbc4.jar:na]在com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:39) com.microsoft.sqlserver.jdbc.SQLServerConnection $ 1ConnectionCommand.doExecute(SQLServerConnection.java:1756)处的[sqljdbc4.jar:na] com.microsoft.sqlserver.jdbc.TDSCommand.execute处的[sqljdbc4.jar:na] IOBuffer.java:5696)到com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715)到[sqljdbc4.jar:na]到com.microsoft.sqlserver.jdbc的[sqljdbc4.jar:na]。 SQLServerConnection.connectionCommand(SQLServerConnection.java:1761)〜[sqljdbc4.jar:na]位于com.microsoft.sqlserver.jdbc.SQLServerConnection.rollback(SQLServerConnection.java:1964)〜[sqljdbc4.jar:na]位于weblogic.jdbc。 wrapper.PoolConnection_com_m icrosoft_sqlserver_jdbc_SQLServerConnection.rollback(Unknown Source) ~[wlfullclient.jar:12.1.1.0] icrosoft_sqlserver_jdbc_SQLServerConnection.rollback(未知源)〜[wlfullclient.jar:12.1.1.0]

Connection is closed. 连接已关闭。

Then the next time the application attempts to get a connection from the data source, the following error is thrown: 然后,下次应用程序尝试从数据源获取连接时,将引发以下错误:

java.sql.SQLException: Failed to setAutoCommit to true for pool connection: First we got The server failed to resume the transaction. Desc:4200000012., then we got The server failed to resume the transaction. Desc:4200000012.
        at weblogic.jdbc.wrapper.PoolConnection.init(PoolConnection.java:70) ~[wlfullclient.jar:12.1.1.0]
        at weblogic.jdbc.common.internal.RmiDataSource.getPoolConnectionObj(RmiDataSource.java:639) ~[wlfullclient.jar:12.1.1.0]
        at weblogic.jdbc.common.internal.RmiDataSource.getPoolConnection(RmiDataSource.java:478) ~[wlfullclient.jar:12.1.1.0]
        at weblogic.jdbc.common.internal.RmiDataSource.getConnectionInternal(RmiDataSource.java:558) ~[wlfullclient.jar:12.1.1.0]
        at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:518) ~[wlfullclient.jar:12.1.1.0]
        at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:511) ~[wlfullclient.jar:12.1.1.0]

In the Weblogic log, the following is logged: 在Weblogic日志中,记录以下内容:

<Oct 15, 2013 3:07:50 PM EDT> <Warning> <JDBC> <BEA-001153> <Forcibly releasing inactive/harvested connection "weblogic.jdbc.wrapper.PoolConnection_com_microsoft_sqlserver_jdbc_SQLServerConnection@238607" back into the data source connec
tion pool "MASTERDB", currently reserved by: reclaimed because of init failure before user access. Not because of inactivity..>

It seems to me that the transaction on the connection was never ended. 在我看来,连接上的事务从未间断。 But a rollback was called which I would have thought would end the transaction. 但是调用了回滚,我以为可以结束交易。 And now the next time Weblogic attempts to return the connection, it errors when initializing it. 现在,Weblogic下次尝试返回连接时,它将在初始化时出错。 Any ideas as to what the issue is? 关于这个问题有什么想法吗? We are not explicitly setting auto commit back to true at the end, could that be the issue? 最后,我们没有明确将auto commit设置为true,这可能是问题吗?

Found this suggestion for same similar problem here . 在这里找到了针对同样类似问题的建议。

"Make sure you have the datasource/pool configured to test-on-reserve, and seconds-to-trust = 0." “确保您已将数据源/池配置为进行保留测试,并且信任秒数=0。”

This should solve the issue of eliminating those "bad" connections from pool before returning to application. 这应该解决在返回到应用程序之前从池中消除那些“不良”连接的问题。

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

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