How to reuse code that reopens connection?

后端 未结 4 1735
旧时难觅i
旧时难觅i 2020-12-22 00:36

Our production server kills inactive connections, so our API needs to restore them when they are needed. The following code works, but it is very repetitive:



        
4条回答
  •  佛祖请我去吃肉
    2020-12-22 01:13

    The common part for those method is the connection retrieving process. You could create a new static method that is responsible for that called for example retrieve connection that take command as argument and return it if connection is established in other cases throws an exception.

提交回复
热议问题