I am using Spring boot with Mysql. I have implemented Datasource and defined properties in application.xml file.
I have a long running query:
@Query(value - "select sleep(10)", nativeQuery=true)
public void test();
in JPA repository methods.
I want to implement query timeout here. I tried using @Transactional(timeout = <>) but I do not want to use that as I will have to do this for all DB methods. I want a global solution.
I also tried setting javax.persistance.query.timeout but I think mysql does not support the same. Any suggesstions on how to implement query timeout with mysql and spring boot?
2
Answers
I don’t know. but I know how to set
connection-timeout
If you use springboot default datasource you can try this config in your
application.yml
You can set a global property, but can also specify that per session or query: Query