我们在项目中使用 ppas9.3 数据库和 hibernate3。我们正在使用一个已经在调用另外两个方法的方法。在一种方法中,我们正在执行“选择”查询(因为那个原因而无法执行'column doesn't exist'
),并且在关闭此连接(即 jdbc 连接)之后,我们正在调用第二种方法,该方法在第一次失败后执行,这次我们通过使用连接'HibernateUtils.getCurrentSession().connection'
并且在执行选择查询(在数据库中成功执行)时出现以下错误:-
BasicAction: a0028c9:d2ba:53c51ef5:6e4 status: ActionStatus.ABORT_ONLY > cannot proceed STATUS_MARKED_ROLLBACK; - nested throwable: (javax.tra
nsaction.RollbackException: Transaction TransactionImple < ac, BasicAction: a0028c9:d2ba:53c51ef5:6e4 status: ActionStatus.ABORT_ONLY > cannot proceed STATUS
_MARKED_ROLLBACK)
18:14:08,475 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
javax.ejb.EJBTransactionRolledbackException: [2] An exception has occurred: ERROR: current transaction is aborted, commands ignored until end of transaction
block
at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
at org.jboss.aspects.tx.TxInterceptor$Supports.invoke(TxInterceptor.java:148)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:304)
at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:81)
at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:107)
at $Proxy145.checkHistory(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.datagenic.infra.WebServiceAdapterInterceptor.executeCall(WebServiceAdapterInterceptor.java:178)
at com.datagenic.infra.WebServiceAdapterInterceptor.intercept(WebServiceAdapterInterceptor.java:82)
at sun.reflect.GeneratedMethodAccessor375.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
当第一条语句没有抛出任何错误时,第二条也可以正常工作。我检查的是:- 1. 我在执行第一条语句之前使用了一个保存点,如果出现错误,我会回滚到该保存点。2. 尝试在没有保存点的情况下回滚。但每次都在第二种方法中出错。方法代码是:-
private String buildItems() {
try {
loadItemsForInfos();
addItems();
} catch (RuntimeException e) {
e.getPrintStack();
}
}
第一种方法是:-
public void loadValueForInfos(){
ResultSet rs = null;
Connection conn = getDSConnection(); // we are taking connection through JNDI name.
PreparedStatement pst = conn.prepareStatement("select * from items where id = ?")//this query by default fails to execute.
pst.setObject(1,12);
try{
rs = executeQuery();
while (rs.next()){
//have some code..
}
}catch(SQLException e){
} finally {
SqlUtils.closeResources(pst, rs);
}
第二种方法是:-
public void addItems() {
String query = "select * from particularitems where id = ?";
PreparedStatement stmt = null;
ResultSet rs = null;
Connection conn = null;
try {
conn = HibernateUtil.currentSession().connection();
stmt = conn.prepareStatement(query);
stmt.setInt(1, 34);
rs = stmt.executeQuery();
while (rs.next()) {
}
} catch (Exception se) {
throw new Exception(se);
} finally {
SqlUtils.closeResources(stmt, rs);
}
}
仅当第一个查询无法执行时才会出现此错误,即使第二个查询正确意味着执行成功。
我们正在使用
auto commit off;
所以你能告诉我确切的原因,我该如何解决它。谢谢,