How to use Java.sql.Connection.setNetworkTimeout?

后端 未结 2 1603
星月不相逢
星月不相逢 2021-01-05 09:47

I ran into the exact issue that setNetworkTimeout is supposed to solve according to Oracle. A query got stuck in socket.read() for several minutes.

But I have little

2条回答
  •  情歌与酒
    2021-01-05 10:13

    As far as Postgres JDBC driver is concerned (postgresql-42.2.2.jar), the setNetworkTimeout implementation does not make use of the Executor parameter. It simply sets the specified timeout as the underlying socket's timeout using the Socket.setSoTimeout method.

    It looks like the java.sql.Connection interface is trying not to make any assumptions about the implementation and provides for an executor that may be used if the implementation needs it.

提交回复
热议问题