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;
}
