I am building a web application which uses MSSQL in backend to fetch queries. I am using SpringBoot and Hibernate .
Now , if the database is down , it takes over 2 minutes for my query to timeout and throw below exception
org.hibernate.exception.JDBCConnectionException: Could not open connection
How to decrease the timeout in my application so that my queries timeout earlier in case db is down?
You can configure the timeout using JPA's javax.persistence.query.timeout
property. The value is the timeout period in milliseconds. It's an optional part of the JPA spec, but Hibernate supports it. You can configure it in Spring Boot by adding the following to application.properties
:
spring.jpa.properties.javax.persistence.query.timeout=60000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With