i have a java program that is calling a Mysql stored procedure that is rolling back when it gets an SQLException. When i added the rollback (exit handler) to the store procedure the java program stopped getting the sql exception. i need for the java program to get a sql exception and the error message from mysql.
does any one know how this is done?
here is my store procedure:
DELIMITER $$
DROP PROCEDURE IF EXISTS up_OMS_insertParticipantOmsOrderOwner $$
CREATE PROCEDURE up_OMS_insertParticipantOmsOrderOwner(
IN PID int,
IN OwnerName varchar(50),
IN DisplayName varchar(50),
IN Enabled tinyint(1))
BEGIN
declare exit handler for SQLException
BEGIN
rollback;
END;
start transaction;
if (DisplayName<>'') then
insert OmsOrderOwner (ParticipantID, OmsOrderOwnerName, DisplayName, Enabled)
value (PID, OwnerName,DisplayName, Enabled);
else
insert OmsOrderOwner(ParticipantID, OmsOrderOwnerName, DisplayName, Enabled)
value (PID, OwnerName,null, Enabled);
end if;
set @OwnerID := @@identity;
insert UserOmsOrderOwnerSubscription (UserID, ParticipantID, OmsOrderOwnerID, Enabled)
select
userOrderSub.UserId, PID, @OwnerID, 1
from
Users u,
UserOmsOrderSubscription userOrderSub
where
userOrderSub.UserID = u.UserID and
u.ParticipantID = PID;
commit;
END $$
DELIMITER ;