使用otl,报错:mysql Commands out of sync; you can't run this command now
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了使用otl,报错:mysql Commands out of sync; you can't run this command now,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2051字,纯文字阅读大概需要3分钟。
内容图文
![使用otl,报错:mysql Commands out of sync; you can't run this command now](/upload/InfoBanner/zyjiaocheng/449/22f4f8e100ec4c94bd5baa1efd9028c2.jpg)
2、执行otl_stream stream2(100, sql2, otlConn,otl_implicit_select);的时候出错,如下:
Commands out of sync; you can‘t run this command now
3、错误原因:mysql上一次的查询没有将结果集释放掉,又进行下一次的查询。
4、otl:在第一个stream读取期间,第二个stream使用了绑定变量,会导致上面的问题,不知道otl内部是怎么封装的。
5、解决办法:
a、第二个stream不使用绑定变量,如下:
void TestCache(otl_connect& otlConn) { try { char sql[1024] = {0}; sprintf(sql,"call test1(1)"); otl_stream stream(100, sql, otlConn,otl_implicit_select); int id; while(!stream.eof()) { stream>>id; char sql2[1024] = {0}; sprintf(sql2,"call test2(%d)",id); otl_stream stream2(100, sql2, otlConn,otl_implicit_select); while(!stream2.eof()) { int ff =0; } } } catch(otl_exception& ex) { printf("ExecuteSql Error, ErrorMsg[%s], Sql[%s]", ex.msg, ex.stm_text); } }
b、先把第一个stream读取完,再进行第二个stream,如下:
void TestCache(otl_connect& otlConn) { try { char sql[1024] = {0}; sprintf(sql,"call test1(1)"); otl_stream stream(100, sql, otlConn,otl_implicit_select); vector<int> intVec; int id; while(!stream.eof()) { stream>>id; intVec.push_back(id); } for(vector<int>::iterator iter = intVec.begin(); iter != intVec.end(); ++iter) { char sql2[1024] = {0}; sprintf(sql2,"call test2(:Id<int>)"); otl_stream stream2(100, sql2, otlConn,otl_implicit_select); stream2<<id; while(!stream2.eof()) { int ff =0; } } } catch(otl_exception& ex) { printf("ExecuteSql Error, ErrorMsg[%s], Sql[%s]", ex.msg, ex.stm_text); } }
使用otl,报错:mysql Commands out of sync; you can't run this command now
标签:
本文系统来源:http://www.cnblogs.com/nzbbody/p/4540738.html
内容总结
以上是互联网集市为您收集整理的使用otl,报错:mysql Commands out of sync; you can't run this command now全部内容,希望文章能够帮你解决使用otl,报错:mysql Commands out of sync; you can't run this command now所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。