Currently, I'm running long running MySQL queries using Java Spring JDBC library. For this program, I want a way of stopping a running query. I want to do this programmatically, so killing processes is not what I need here.
Also, setting timeouts and killing threads using Java code is not preferred.
Is there a way to do this using programming conventions, or is there any preferred way or design to achieve this use case in Java?