You cannot rollback during a managed transaction

1 resposta
jason_bourne

Pessoal,

Não estou conseguindo dar rollback nessa procedure. Aparece You cannot rollback during a managed transaction. Alguém pode me ajudar?

public synchronized Long atualizaFiscal(ImportDTO itemImp,Long codInterface, PerfilDTO perfil) 
	throws BusinessException{

		Long retorno = null;

		CallableStatement cst;
		try {
			Context initCtx = new InitialContext(); 
			//InitialContext initCtx = new InitialContext();
			Context ctx = (Context) initCtx.lookup("java:/");
			DataSource ds = (DataSource) ctx.lookup("jdbc/mpaOracleDS");
			conn = ds.getConnection();
			//conn.setAutoCommit(false); 

			
			cst = conn.prepareCall("{call PG_GEN.PR_UP(?,?,?,?,?,?,?,?,?,?,?,?)}");
			

			System.out.println("PG_GEN.PR_UP('IOB','"+AbstractDAO.PARAM_COD_SISTEMA+"','"+itemImp.getCodigo()+"','"+itemImp.getDescSug()+"',"+itemImp.getNcmSug()+","+itemImp.getCodExNcmSug()+","+itemImp.getCodAcao()+",'"+itemImp.getMotivoRejeicao()+"','"+itemImp.getDuvida()+"','"+itemImp.getResposta()+"','"+perfil.getNomeLoginUsuario()+"',RETORNO)");

			cst.setString(1, "IOB");
			cst.setString(2, AbstractDAO.PARAM_COD_SISTEMA);
			cst.setLong(3, itemImp.getCodigo());
			cst.setString(4, itemImp.getDescSug());
			cst.setString(5, itemImp.getNcmSug());
			cst.setString(6, itemImp.getCodExNcmSug());
			cst.setLong(7, itemImp.getCodAcao());
			cst.setString(8, itemImp.getMotivoRejeicao());
			cst.setString(9, itemImp.getDuvida());
			cst.setString(10, itemImp.getResposta());
			cst.setString(11, perfil.getNomeLoginUsuario());
			cst.registerOutParameter(12, java.sql.Types.NUMERIC);
			cst.execute();		
			retorno = cst.getLong(12);

			if("0".equals(retorno)){
				try {
					conn.rollback();
				} catch (SQLException e) {
					e.printStackTrace();
					throw new BusinessException(e.toString(),e);
				}
			}

		} catch (SQLException e) {
			e.printStackTrace();
			try {
				
				
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			throw new BusinessException(e.toString(),e);
		} catch (NamingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		return retorno;
	}

1 Resposta

WRYEL

um tempo muito remoto, quando eu fucei com oracle + java, coisa de uns tres anos, se eu não me engano eu fazio algo como:

blabla.setAutoCommit(false);  
blabla.begin(); //não lembro se é esse o nome do metodo, mas lembro que  gente avisava que tava inciando uma transação
.... // procedimentos ...
blabla.commit();
// ou
blabla.rollback();

jaja aparece algum pra acender nossa luz se não for isso :slight_smile:

Criado 2 de setembro de 2009
Ultima resposta 2 de set. de 2009
Respostas 1
Participantes 2