1. 程式人生 > >Could not open Hibernate Session for transaction; nested exception is org.hibernate.TransactionExcep linux下mysql修改連接超時wait_timeout修改後就ok了

Could not open Hibernate Session for transaction; nested exception is org.hibernate.TransactionExcep linux下mysql修改連接超時wait_timeout修改後就ok了

有用 linux下 net ans ack delayed 線上 nec 宋體

Linuxmysql修改連接超時wait_timeout

1,首先:

show variables like ‘%timeout%‘

顯示結果:

+-----------------------------+----------+

| Variable_name | Value |

+-----------------------------+----------+

| connect_timeout | 10 |

| delayed_insert_timeout | 300 |

| innodb_flush_log_at_timeout | 1 |

| innodb_lock_wait_timeout | 50 |

| innodb_rollback_on_timeout | OFF |

| interactive_timeout | 28800 |

| lock_wait_timeout | 31536000 |

| net_read_timeout | 30 |

| net_write_timeout | 60 |

| rpl_stop_slave_timeout | 31536000 |

| slave_net_timeout | 3600 |

| wait_timeout | 28800 |

+-----------------------------+----------+

12 rows in set (0.00 sec)

其中有用的是: interactive_timeout wait_timeout 28800,默認為8小時設置;

一般線上的環境中mysql中連接時間設置為7天即可;

2,其次:

執行命令: set interactive_timeout=604800

set wait_timeout=604800

最後:執行?show variables like ‘%timeout%‘;看看執行成功沒有,顯示結果為:

?

+-----------------------------+----------+

| Variable_name | Value |

+-----------------------------+----------+

| connect_timeout | 10 |

| delayed_insert_timeout | 300 |

| innodb_flush_log_at_timeout | 1 |

| innodb_lock_wait_timeout | 50 |

| innodb_rollback_on_timeout | OFF |

| interactive_timeout | 604800 |

| lock_wait_timeout | 31536000 |

| net_read_timeout | 30 |

| net_write_timeout | 60 |

| rpl_stop_slave_timeout | 31536000 |

| slave_net_timeout | 3600 |

| wait_timeout | 604800 |

+-----------------------------+----------+

12 rows in set (0.00 sec)

表明執行成功了。。。

Could not open Hibernate Session for transaction; nested exception is org.hibernate.TransactionExcep linux下mysql修改連接超時wait_timeout修改後就ok了