在数据库函数的使用中使用什么函数,使分数值在100以内

mysql连接的空闲时间超过8小时后 MySQL自动断开该连接解决方案
字体:[ ] 类型:转载 时间:
MySQL 的默认设置下,当一个连接的空闲时间超过8小时后,MySQL 就会断开该连接,而 c3p0 连接池则以为该被断开的连接依然有效。在这种情况下,如果客户端代码向 c3p0 连接池请求连接的话,连接池就会把已经失效的连接返回给客户端,客户端在使用该失效连接的时候即抛出异常
解决这个问题的办法有三种: 1. 增加 MySQL 的 wait_timeout 属性的值。 修改 /etc/f文件,在 [mysqld] 节中设置: # Set a connection to wait 8hours in idle status. wait_timeout =86400 相关参数,红色部分 mysql& show variables like '%timeout%'; +--------------------------+-------+ | Variable_name | Value | +--------------------------+-------+ | connect_timeout | 5 | | delayed_insert_timeout | 300 | | innodb_lock_wait_timeout | 50 | | interactive_timeout | 28800 | | net_read_timeout | 30 | | net_write_timeout | 60 | | slave_net_timeout | 3600 | | wait_timeout | 28800 | +--------------------------+-------+ 同一时间,这两个参数只有一个起作用。到底是哪个参数起作用,和用户连接时指定的连接参数相关,缺省情况下是使用wait_timeout。我建议是将这两个参数都修改,以免引起不必要的麻烦。 这两个参数的默认值是8小时(60*60*8=28800)。我测试过将这两个参数改为0,结果出人意料,系统自动将这个值设置为。换句话说,不能将该值设置为永久。 将这2个参数设置为24小时(60*60*24=604800)即可。 set interactive_timeout=604800; set wait_timeout=604800; 2. 减少连接池内连接的生存周期,使之小于上一项中所设置的 wait_timeout 的值。 修改 c3p0 的配置文件,设置: # How long to keep unused connections around(in seconds) # Note: MySQL times out idle connections after 8hours(28,800seconds) # so ensure this value is below MySQL idle timeout cpool.maxIdleTime=25200 在 Spring 的配置文件中:
代码如下: &bean id="dataSource" class="com.mchange.boPooledDataSource"& &property name="maxIdleTime"value="${cpool.maxIdleTime}"/& &!--other properties --& &/bean&
3. 定期使用连接池内的连接,使得它们不会因为闲置超时而被 MySQL 断开。 修改 c3p0 的配置文件,设置: # Prevent MySQL raise exception after a long idle timecpool.preferredTestQuery='SELECT 1'cpool.idleConnectionTestPeriod=18000cpool.testConnectionOnCheckout=true 修改 Spring 的配置文件:
代码如下: &bean id="dataSource" class="com.mchange.boPooledDataSource"& &property name="preferredTestQuery" value="${cpool.preferredTestQuery}"/& &property name="idleConnectionTestPeriod" value="${cpool.idleConnectionTestPeriod}"/& &property name="testConnectionOnCheckout" value="${cpool.testConnectionOnCheckout}"/& &!--other properties --&&/bean&
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具mysql&8小时解决方案
异常:com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException:
Connection.close() has already been called. Invalid operation in
this state.
ysql 8小时解决方案
解决这个问题的办法有三种:&
1. 增加 MySQL 的 wait_timeout 属性的值。&
修改 /etc/f文件,在 [mysqld] 节中设置:&
同一时间,这两个参数只有一个起作用。到底是哪个参数起作用,和用户连接时指定的连接参数相关,缺省情况下是使用wait_timeout。我建议是将这两个参数都修改,以免引起不必要的麻烦。
这两个参数的默认值是8小时(60*60*8=28800)。我测试过将这两个参数改为0,结果出人意料,自动将这个值设置为。换句话说,不能将该值设置为永久。&
将这2个参数设置为24小时(60*60*24=604800)即可。&
set interactive_timeout=604800;&
set wait_timeout=604800;&
2. 减少连接池内连接的生存周期,使之小于上一项中所设置的 wait_timeout
修改 c3p0 的配置文件,设置:&
# How long to keep unused connections around(in
# Note: MySQL times out idle connections after
8hours(28,800seconds)&
# so ensure this value is below MySQL idle
cpool.maxIdleTime=25200&
在 Spring 的配置文件中:
Java代码 &
class="com.mchange.boPooledDataSource"&
3. 定期使用连接池内的连接,使得它们不会因为闲置超时而被 MySQL 断开。&
修改 c3p0 的配置文件,设置: &
# Prevent MySQL raise exception after a long idle
timecpool.preferredTestQuery='SELECT
1'cpool.idleConnectionTestPeriod=18000cpool.testConnectionOnCheckout=true&
修改 Spring 的配置文件:
Java代码 &
4、DBCP配置
minEvictableIdleTimeMillis
&1000 * 60 * 30
&连接在池中保持空闲而不被空闲连接回收器线程
(如果有)回收的最小时间值,单位毫秒
//set&to&'SELECT&1'&&&
validationQuery&=&"SELECT&1"&&&
//set&to&'true'&&&
testWhileIdle&=&"true"&&&
//some&positive&integer&&&
timeBetweenEvictionRunsMillis&=&3600000&&&
//set&to&something&smaller&than&'wait_timeout'&&&
minEvictableIdleTimeMillis&=&&&&
//if&you&don't&mind&a&hit&for&every&getConnection(),&set&to&"true"&&&
testOnBorrow&=&"true"&
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。mysql(2)
SHOW GLOBAL VARIABLES //查看mysql默认的参数表
//设置为800小时
SET GLOBAL&wait_timeout = 2880000//设置参数表:默认28800
SET GLOBAL interactive_timeout = 2880000//设置参数表默认:28800
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:5270次
排名:千里之外
原创:29篇
转载:16篇
(8)(7)(1)(2)(6)(1)(5)(1)(14)}

我要回帖

更多关于 数据库中min函数使用 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信