java.sql.SQLException:您不能在托管事务期间提交 [英] java.sql.SQLException: You cannot commit during a managed transaction
本文介绍了java.sql.SQLException:您不能在托管事务期间提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在jboss 7中,我具有以下配置
In jboss 7, I have below config
<datasource jndi-name="java:jboss/env/esilicon/vms/OracleDBPoolNonXA" pool-name="ExampleDS">
<connection-url>jdbc:oracle:thin:@erptstdb.sc.kaka.com:14100:ERPTST</connection-url>
<driver>XAOracleJDBCDriver</driver>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>20</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>apps</user-name>
<password>apps</password>
</security>
</datasource>
<drivers>
<driver name="XAOracleJDBCDriver" module="oracle.jdbc">
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
</driver>
</drivers>
在其他类中,我有方法来获取数据源的连接
In orther class, I've method to get the connection for datasource
public static Connection getNonXAConnection() {
try {
InitialContext context = new InitialContext();
DataSource dataSource = (DataSource)context.lookup(JNDILookup.PURE_CONNECTION_JNDI);
return dataSource.getConnection();
} catch (Exception e) {
e.printStackTrace();
logger.fatal(e.getMessage(), e.getCause());
}
return null;
}
我提交此连接时发生错误
The error occur when I commit this connection
java.sql.SQLException: You cannot commit during a managed transaction!
at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManagedConnection.java:981)
at org.jboss.jca.adapters.jdbc.WrappedConnection.commit(WrappedConnection.java:757)
我只是想获得连接并执行一些存储过程,并最终提交此连接.请帮助我
I just like to get connection and execute some stored procedure, and finnaly commit this connection. Please help me
推荐答案
使用这样的注释:
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
public class SchedulerBean {
我在Quartz上也遇到了同样的问题,并且能够通过这种方式解决.
I was facing same problem with Quartz and was able to solve this way.
这篇关于java.sql.SQLException:您不能在托管事务期间提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文