It might be some some more ways to do it. it heavily depends on your database. For example in Oracle there is a "Alter session kill process ..." command which you can embed in a stored procedure or directly calling using createNativeQuery.