我正在使用Postgresql(9.6.3),我需要为Wait_timeout变量设置值。但是我没有找到与此相关的任何答案,也没有找到可以在Postgresql中使用的等效变量,而不是MySQL中的wait_timeout变量。
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变量中得到空值。我发现了一个名为Statement_timeout的变量,但我不知道它是否等效,因为它可能会影响所有其他会话,而MySQL中的wait_timeout却不会。请给我建议一个更好的解决方案。预先感谢。
答案 0 :(得分:1)
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
说实话,到目前为止,除了“ connect_timeout”外,我不需要摆弄MySQL中的这些超时。所以我不能给你直接的建议。但是也许您需要“ idle_in_transaction_session_timeout”。