mysql 连接数过多 包错:"Host '192.168.10.15' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

mysql 连接数过多 包错:"Host '192.168.10.15' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"

a123456678 2016-03-17 09:41:50 2453

1.用阿里的连接池 配置如下:

<bean id="Template_DataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close"> 
   <property name="url" value="jdbc:mysql://10.96.9.105/smg?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true&amp;zeroDateTimeBehavior=convertToNull" />
   <property name="username" value="root" />
   <property name="password" value="" />
   <property name="filters" value="stat" />
   <property name="maxActive" value="20" />
   <property name="initialSize" value="1" />
   <property name="maxWait" value="60000" />
   <property name="minIdle" value="1" />
   <property name="timeBetweenEvictionRunsMillis" value="60000" />
   <property name="minEvictableIdleTimeMillis" value="300000" />
   <property name="validationQuery" value="SELECT 'x'" />
   <property name="testWhileIdle" value="true" />
   <property name="testOnBorrow" value="false" />
   <property name="testOnReturn" value="false" />
   <property name="poolPreparedStatements" value="true" />
   <property name="maxPoolPreparedStatementPerConnectionSize" value="20" />
    </bean>

2.spring 对数据库操作:

private JdbcTemplate getJdbcTemplate() {
JdbcTemplate jt = (JdbcTemplate) this.getApplicationContext().getBean("Template_JdbcTemplate");
return jt;
}

public boolean update(String sql) {
int i = this.getJdbcTemplate().update(sql);
return i > 0;
}
场景:该应用定时的更新数据库表(每20min) 请问问题出在哪里?

SQL 关系型数据库 MySQL Java 数据库连接 数据库
分享到
取消 提交回答
全部回答(1)
  • a123456678
    2019-07-17 19:04:31

    1、设置下max_connection_errors的数量

    2、清理下host

    0 0
+ 订阅

分享数据库前沿,解构实战干货,推动数据库技术变革

推荐文章
相似问题