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登陆 ...
随机推荐
- Concurrency Managed Workqueue(一)workqueue基本概念
一.前言 workqueue是一个驱动工程师常用的工具,在旧的内核中(指2.6.36之前的内核版本)workqueue代码比较简单(大概800行),在2.6.36内核版本中引入了CMWQ(Concur ...
- 使用用户自定义类型作为map的key
有时候我们想把用户自定义类型作为std::map的键值.方法一)最简单的方法就是实现该自定义类型的<操作符,代码如下:class Foo{public: Foo(int num_) ...
- Latex 附录生成方法-附使用的一些tips
Latex 附录生成方法-附使用的一些tips 工具 使用latex写论文时,国内科研人员使用比较多的前端工具当属CTex,另外的前度工具有texstdio,texworks,sublime,甚至vi ...
- javascript Dictionary data structures
Dictionary常被称为数据字典,是一种用来保存键值对的数据结构,比如我们日常的电话本,就是一个Dictionary.我们通过键(名字),就可以访问到对应的值(电话号码).在C++与java中我们 ...
- Linux操作系统CentOS7.2发行版本的安装与配置(安装是选择服务器类型)
原文地址:http://1130739.blog.51cto.com/1120739/1738791 由于CentOS 7出来不久,对于这个版本的系统安装与配置的教程较少,今天就索性介绍一下CentO ...
- Qt Quick + OpenGL + Bullet初次測试
Qt Quick + OpenGL + Bullet初次測试 眼下Qt的Quick模块已经表现得很出色,并且可以预留接口来渲染OpenGL场景.一般来说,已经可以满足大部分编程须要了.这次呢.尝试使用 ...
- Xilinx之RAM使用指南
一. RAM 分类XILINX 的 RAM 可分为三种,分别是:单口 RAM,简化双口 RAM 和真双口 RAM.如下 图所示: 图1 单口 RAM 图2 简化双口 RAM A 口写入数据,B 口读数 ...
- 关于Xilinx MicroBlaze应用modelsim se仿真问题(EDK:3593 - Unable to locate the precompiled library microblaze_v8_50_c)
ERROR:EDK:3593 - Unable to locate the precompiled library microblaze_v8_50_c. The file D:\Xilinx\14. ...
- 【Android】8.2 动态选择和设置主题
分类:C#.Android.VS2015: 创建日期:2016-02-17 一.简介 除了通过Theme指定主题外,还可以在程序运行时动态指定并应用主题. 二.示例-ch0802ThemeDemo 1 ...
- Set 集合论
https://en.m.wikipedia.org/wiki/De_Morgan%27s_laws https://plato.stanford.edu/entries/set-theory/ ht ...