Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

执行多次qbs.Exec后报1461错误 #43

Closed
elephantsaunter opened this issue Jan 25, 2014 · 3 comments
Closed

执行多次qbs.Exec后报1461错误 #43

elephantsaunter opened this issue Jan 25, 2014 · 3 comments

Comments

@elephantsaunter
Copy link

请教,在执行多次qbs.Exec(sql)后,会报这个错误
1461: Can' t create more than max_prepared_stmt_count statements (current value: 16382)
数据库显示:
| Com_stmt_close | 456 |
| Com_stmt_execute | 132936 |
| Com_stmt_fetch | 0 |
| Com_stmt_prepare | 91187 |
请问,要在哪进行com_stmt_close关闭

@coocood
Copy link
Owner

coocood commented Jan 25, 2014

你是不是把参数直接放到query里了,不然不会那么多prepared statement.
应该是q.Exec("SELECT * FROM user WHERE name=?", name)
而不是q.Exec("SELECT * FROM user WHERE name="+name)

@elephantsaunter
Copy link
Author

是的,q.Exec(sql)中sql参数,是在其它模块组装好的。
是一串string
我这种调用方式,怎样来避免这个问题?

@coocood
Copy link
Owner

coocood commented Jan 25, 2014

把不变的sql语句和参数分开,参数放在后面的args里。
如果你不能改其他模块,那就没办法了。
正规用法一定是要把语句和参数分开的。

On Sat, Jan 25, 2014 at 3:59 PM, huyan notifications@github.com wrote:

是的,q.Exec(sql)中sql参数,是在其它模块组装好的。

是一串string

我这种调用方式,怎样来避免这个问题?


Reply to this email directly or view it on GitHubhttps://github.com//issues/43#issuecomment-33283612
.

@coocood coocood closed this as completed Feb 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants