MySql: ”Commands out of sync“Error (Connect/C++)
使用 Connector/C++ 查询 Mysql , 连续调用存储过程时
会出现如下:
Commands out of sync; you can't run this command now,state:HY000
出现原因可以看这里:http://stackoverflow.com/questions/17115919/mysql-commands-out-of-sync-error-c-connector
这一句:
Because CALL can return multiple results, process them using a loop that calls mysql_next_result() to determine whether there are more results. "
Connector/C++ 封装后,使用 getMoreResults() 函数来读取下一个 resultset;
例子如下:
// 查询存储过程
prepareState.reset(con->prepareStatement("call test.testproc1(?)"));
prepareState->setInt(,);
prepareState->executeUpdate(); result.reset(prepareState->getResultSet());
// 输出结果
while(result->next())
{
int id = result->getInt("id");
string name = result->getString("name");
} while(prepareState->getMoreResults()) //注意这里, 调用 getMoreResults() 把所有的 resultset读出来
{
result.reset(prepareState->getResultSet()); //对下一组result set 做某些东西
}
prepareState.reset(con->prepareStatement("call test.testproc3(?)"));
prepareState->setInt(,);
prepareState->executeUpdate(); result.reset(prepareState->getResultSet());
// 输出结果
while(result->next())
{
int id = result->getInt("id");
string name = result->getString("name");
} while (prepareState->getMoreResults())
result.reset(prepareState->getResultSet());
MySql: ”Commands out of sync“Error (Connect/C++)的更多相关文章
- 使用otl,报错:mysql Commands out of sync; you can't run this command now
1.代码如下: void TestCache(otl_connect& otlConn) { try { ] = {}; sprintf(sql,"call test1(1)&quo ...
- python mysql 2014 Commands out of sync; you can't run this command now
这个问题出现再 mysql和c 的api. 简单的解决方法是不使用api直接把整个连接和命令传过去. 例如,cmd = 'mysql -h 192.168.32.210 -P 3316 -u bfd ...
- error:2014 Commands out of sync; you can't run this command now
如下错误: 分析原因: 前端ajax请求后台,共用同一个链接. 搜索别人的解决方案:http://blog.csdn.net/grass_ring/article/details/3499402 用m ...
- mysql绿色版安装问题解决(ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061))
原来一直是使用MySQL安装版没有出现过问题,今天在安装绿色版MySQL时出现了点问题 在安装成windows服务成功后,用net start mysql 启动时提示启动成功,但当我连接mysql就报 ...
- 在启动MYSQL时出现问题:“ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)”
1.问题描述 在启动MYSQL时出现问题:"ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)& ...
- 一则奇怪的案例处理:ORA-00257: archiver error. Connect internal only, until freed
前天,业务反应数据库不能连接 在操作系统通过字符串尝试登陆数据库报:ORA-00257: archiver error. Connect internal only, until freed 解决思路 ...
- 【Oracle】ORA-00257:archiver error. Connect internal only, until freed 错误的处理方法
archive log 日志已满ORA-00257: archiver error. Connect internal only, until freed 错误的处理方法 1. 用sys用户登录 s ...
- mysql闪退或者can not connect 127.0.0.1
MYSQL 无安装文件 exe执行时闪退 mysql闪退或者can not connect 127.0.0.1 APP 百款主流机型兼容性免费测 » Mysql 官网上下载的Mysql 但是没有 ...
- ORA-00257: archiver error. Connect internal only, until freed——解决
参考http://www.2cto.com/database/201109/104615.html, 开启归档后,操作一个大表迁移表空间,执行了1个多小时没完成就手动给中断了,但是再次用plsql登陆 ...
随机推荐
- Hadoop docs
原文地址:http://hadoop.apache.org/docs/ Index of /docs Name Last modified Size Description Parent Direct ...
- Zookeeper监控工具
Zookeeper的常用开源监控工具可以参考:http://zqhxuyuan.github.io/2016/12/31/BigData-Monitor-Tool
- configure: error: png.h not found.
PHP的时候提示这个错误 configure: error: png.h not found.,这个是选择安装GD模块才会出现的错误,详细错误信息如下 If configure fails try - ...
- AR_销售订单收款基本操作(流程)
2014-06-04 Created By BaoXinjian
- Unix环境高级编程(十)信号续
1.signal函数 Unix系统的信号机制最简单的接口是signal函数,函数原型如下: #include <signal.h> typedef void (*sighandler_t) ...
- java 又一次抛出异常 相关处理结果演示样例代码
java 又一次抛出异常 相关处理结果演示样例代码 package org.rui.ExceptionTest; /** * 又一次抛出异常 * 在某些情况下,我们想又一次掷出刚才产生过的违例,特别是 ...
- 基于配置的Spring MVC3
网上查找的spring mvc3大部分都是基于注射的方式,总感觉注射有点怪怪.不利于后期扩展和项目管理,于是特意写下这篇基于xml配置的Spring MVC3.以供大家參考. 怎么建立web项目和下载 ...
- iOS8开发之iOS8的UIAlertController
在iOS8之前用UIActionSheet和UIAlertView来提供button选择和提示性信息,比方UIActionSheet能够这样写: UIActionSheet *actionSheet ...
- sklearn 中的交叉验证
sklearn中的交叉验证(Cross-Validation) sklearn是利用python进行机器学习中一个非常全面和好用的第三方库,用过的都说好.今天主要记录一下sklearn中关于交叉验证的 ...
- 修改ultisnips的默认键
把ultisnips修改和textmate一致. <tab>展开代码,再按<tab>跳转到下一个占位符,<shift+tab>跳转上一个占位符. 在vim配置文件中 ...