I have this error on some situations:
1) On machine with ODBC 3.51
Same query ok on ODBC 5.3 returns that message on ODBC 3.51
2) When update from MySQL 5.6 TO 5.7
I was using INNER JOIN between INT and VARCHAR ( 1 and 0000001 ), this was ok on 5.6.
From 5.7 this is a problem, that requires internal codepage conversion and slow down queries execution
3) A really long time execution query (or do not exists index to optimize query)
4) A query executed by a user with no privileges to do it
5) Connection fail
A first test is try to execute same query on HEIDISQL or anything else, with same user and server, to check result.
If query is the problem, execute again will not solve problem.
Another common problem using connections on Windows:
Before Windows XP service pack 5, half open connections limit was anything about 67 millions, and from service pack 5 limit was reduced to 8, only 8 units.
When close connection, windows move connection to halfopen for a limited time, before really to close it.
connection open/close/open/close/open/close, this can crash application and windows too.
if you are using port 3306 for MySQL, you can check this using
netstat -a | find /i "3306"