我使用Postgresql(9.6.3),需要为Wait_timeout变量设置值。但是,我没有找到与此相关的任何答案,也找不到任何可用于Postgresql而不是MySQL中的MySQL变量的等效变量。
long wait_time = 0;
ResultSet rs = null;
try {
Statement st = con.createStatement();
rs = st.executeQuery("show variables like 'wait_timeout'");
if(rs.next())
wait_time = rs.getLong("Value");
rs.close();
} catch (SQLException e) {
logger.error(e);
}
// wait time in SQl is maintained in seconds whereas here we need
milliseconds
return (wait_time*1000)/2;执行查询后,我将在resultSet变量中获得null值。我已经找到了一个名为Statement_timeout的变量,但我不知道它是否等效,因为它可能会影响所有其他会话,因为wait_timeout在MySQL中没有这样做。请给我一个更好的解决方案。提前谢谢。
发布于 2019-05-28 08:22:50
MySQL实现了很多超时(https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html)。
MySQL有:
PostgreSQL目前有:
(https://www.postgresql.org/docs/11/runtime-config-client.html)
例如,参见这里- https://dba.stackexchange.com/questions/164419/is-it-possible-to-limit-timeout-on-postgres-server
老实说,到目前为止,除了“MySQL”之外,我不需要在connect_timeout中篡改这些超时。所以我不能给你直接的建议。但也许"idle_in_transaction_session_timeout“才是你所需要的。
https://stackoverflow.com/questions/56337335
复制相似问题