Quarkus / Hibernate – 如何设置jdbc连接的TTL?

huangapple go评论75阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年4月6日 21:27:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/75950095.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定