java jdbc mysql连接器:如何在很长的空闲时间后解决断开连接问题 [英] java jdbc mysql connector: how to resolve disconnection after a long idle time

查看:333
本文介绍了java jdbc mysql连接器:如何在很长的空闲时间后解决断开连接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用red5 1.0.0rc1来创建在线游戏。
我正在使用jdbc mysql连接器连接到MySQL数据库v5.1.12

I'm using red5 1.0.0rc1 to create an online game. I'm connecting to a MySQL database using a jdbc mysql connector v5.1.12

似乎在闲置几个小时后我的应用程序可以继续运行查询,因为与数据库的连接已关闭,我必须重新启动应用程序。

it seems that after several hours of idle my application can continue running queries because the connection to the db got closed and i have to restart the application.

如何解决问题?

Kfir

推荐答案

MySQL JDBC驱动程序具有自动重新连接功能,有时可以提供帮助;请参阅驱动程序/数据源类名,URL Connector / J的语法和配置属性,并阅读警告。

The MySQL JDBC driver has an autoreconnect feature that can be helpful on occasion; see Driver/Datasource Class Names, URL Syntax and Configuration Properties for Connector/J, and read the caveats.

根据我的经验,最佳解决方案是更改MySQL配置属性以设置会话空闲超时到一个非常大的数字。

In my experience the best solution is to change the MySQL configuration properties to set the session idle timeout to a really large number.

这篇关于java jdbc mysql连接器:如何在很长的空闲时间后解决断开连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆