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登陆 ...
随机推荐
- postgresql命令行[转]
postgresql命令行 原文链接 PostgreSQL 8.1 中文文档 连接数据库, 默认的用户和数据库是postgrespsql -U user -d dbname \c dbname 切换数 ...
- jsp处理表单上传图片(commons-fileupload-1.2.2.jar,commons-io-2.4.jar)
upload.jsp <%@ page language="java" import="java.util.*" pageEncoding="U ...
- xcode 在哪里新建category、protocol等文件
1.和以前新建新文件一样.2.当然选IOS啦,不过OS X也有这个选项,然后Objctive-C File. 3.在File Type里选就OK啦.
- PLSQL_统计信息系列02_统计信息的对象
20150505 Created By BaoXinjian
- DevExpress下拉多选框 CheckComboboxEdit、CheckedListBoxControl
CheckComboboxEdit //清空项 checkedComboBoxEdit1.Properties.Items.Clear(); //自定义数组 ...
- How to set JAVA environment variables in Linux or CentOS
How to set JAVA environment variables JAVA_HOME and PATH in Linux After installing new java (jdk or ...
- Spring AOP之Introduction(@DeclareParents)简介(转)
Spring的文档上对Introduction这个概念和相关的注解@DeclareParents作了如下介绍: Introductions (known as inter-type declarati ...
- ps减去图层混合模式
ps减去图层混合模式 CMYK 1.1.青色作为基色,品红作为混合色(减去混合模式) 红反即青色(绿色+蓝色) - 绿反即品红色(红色+蓝色)= 绿色 公式简化: 绿色 + 蓝色 - 红色 - 蓝 ...
- CF 366E - Dima and Magic Guitar 最远曼哈顿距离
题目:http://codeforces.com/problemset/problem/366/E 事实上就是找 n * m 矩阵中数字 x 和 数字 y 的最远距离. 方法參照武森的论文<浅谈 ...
- mysql 的S 锁和X锁的区别
共享锁和排它锁 MySQL的锁系统:shared lock和exclusive lock(共享锁和排他锁,也叫读锁和写锁,即read lock和write lock) 读锁是共享的,或者说是相互不阻塞 ...