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?
stmt.cancel()with your database and your driver and your use case if it realy works...jdbctemplateyou should tag the question accordingly.cancelis a plain JDBC function with which you tagged your question. But it seems you can use it as well in your context.