Set the MAX_STATEMENT_COUNToption to limit the number of prepared statements for a connection can make.
The MAX_STATEMENT_COUNT option limits the maximum number of prepared statements that a connection can use at once. If a server needs to support more than the default number (50) of prepared statements at any one time for any one connection, then you can set the MAX_STATEMENT_COUNT option to a higher value