I created a stored procedure in MySQL and called it from a Java application with JPA EclipseLink. Once the procedure is called, it has a "sleep(sec)" method inside, and then it executes something successfully unless the application is turned off, it seems like the procedure is canceled too which is not what I want. The same thing I tried using JDBC PreparedStatements, the same result. Is there any workaround to make the stored procedure work even if the app was shut down after the procedure call.
Stored Procedure
DELIMITER //
DROP PROCEDURE IF EXISTS session_procedure//
CREATE PROCEDURE session_procedure
(
IN userID INT
)
BEGIN
SELECT SLEEP(30);
UPDATE users
SET users.Active = 0
WHERE users.Id = userID;
END//
DELIMITER ;
Procedure call in Java
public static void destroySessionCountdown(EntityManager entityManager, Account akk){
int accountId = akk.getId();
StoredProcedureQuery storedProcedure = entityManager.createStoredProcedureQuery("session_procedure");
storedProcedure.registerStoredProcedureParameter(1, Integer.class, ParameterMode.IN);
storedProcedure.setParameter(1, accountId);
try {
storedProcedure.execute();
}catch(Exception e){
e.printStackTrace();
}
// force logout
}