Can't create more than max_prepared_stmt_count statements
Posted studywithallofyou
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Can't create more than max_prepared_stmt_count statements相关的知识,希望对你有一定的参考价值。
使用mysql connector的时候,如果报这个错误
Can‘t create more than max_prepared_stmt_count statements (current value: 16382)
是因为下面的写法有一定问题,如果catch了错误,那么stmt就不会释放,最好是把stmt放到外面,在最后的时候delete,但是一般不会出问题,关键是如果写了bug,导致不断运行catch错误,就会导致preparedstatement大量不会释放,超出默认的16382的个数
try { sql::PreparedStatement * stmt = con->prepareStatement(sqlstr); stmt->setInt(1, id1); stmt->setInt(2, id2); stmt->execute(); delete stmt; } catch (sql::SQLException & e) { bsqlcon = false; Log_Text_Format(LOGLEVEL_ERROR, "Err: SQLException in %s %s %d ERR[%s] ErrCode[%d] SQLState[%s] sql[%s]", __FILE__, __FUNCTION__, __LINE__, e.what(), e.getErrorCode(), e.getSQLState().c_str(), sqlstr.c_str()); }
可以通过下面的语句查看目前申请了几个,使用了几个,释放了几个,正常情况申请的和释放的应该是很接近在几十或是上百个以内,并且固定不变不会逐渐增加。不过申请释放的这个值,如果直接关闭程序,是不会改变的,还是维持最后一次的记录
show global status like ‘com_stmt%‘;
Com_stmt_execute 563281
Com_stmt_close 563280
Com_stmt_fetch 0
Com_stmt_prepare 563359
Com_stmt_reset 0
Com_stmt_send_long_data 0
Com_stmt_reprepare 0
以上是关于Can't create more than max_prepared_stmt_count statements的主要内容,如果未能解决你的问题,请参考以下文章
java SSM项目搭建-- The server time zone value '?й???????' is unrecognized or represents more tha
java.sql.SQLException: The server time zone value ‘�й���ʱ��‘ is unrecognized or represents more tha
Minecraft出错: Can't create cache file!
NodeJs Mysql Cant't create more than max_prepared_stmt_count statements
170318 11:44:26 [ERROR] Can't start server: can't create PID file: No space left on device