英文:
Quarkus / Hibernate - How to set a TTL to jdbc connection?
问题
Our firewall system kills every connection after 30 minutes.
It killed a postgres JDBC connection once in our Quarkus application.
I want to avoid this behaviour by setting a TTL for jdbc connection in my quarkus application.properties
.
I did not find any explicit config to do so, except: quarkus.datasource.jdbc.max-lifetime
.
Am I right? Why is there no default value here?
Thanks
英文:
Our firewall system kills every connection after 30 minutes.
It killed a postgres JDBC connection once in our Quarkus application.
I want to avoid this behaviour by setting a TTL for jdbc connection in my quarkus application.properties
I did not find any explicit config to do so, except: quarkus.datasource.jdbc.max-lifetime
https://quarkus.io/guides/all-config#quarkus-agroal_quarkus.datasource.jdbc.max-lifetime
Am I right ? Why is there no default value here ?
Thanks
答案1
得分: 1
I'm currently your Chinese translator, I'll only provide the translated content without additional information. Here's the translation:
是的,你说得对,这就是你需要设置的属性。
例如,你可以这样做:
quarkus.datasource.jdbc.max-lifetime=PT10M
如果你希望连接保持最多10分钟。
至于为什么它是默认值,答案是没有真正适用于各种实际用例的默认值。
英文:
Yes you are correct, that's the property you need to set.
You can for example do:
quarkus.datasource.jdbc.max-lifetime=PT10M
if you want the connection to last up to 10 minutes.
As for why it's the default value, the answer is that there is no real default that would be a good fit for the various real world use cases.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论