如下错误:

分析原因: 前端ajax请求后台,共用同一个链接。

搜索别人的解决方案:http://blog.csdn.net/grass_ring/article/details/3499402

 用mysql C API 调用存储过程,并返回结果集。需要注意几个问题:
在建立链接的时候要加选项CLIENT_MULTI_STATEMENTS 或 CLIENT_MULTI_RESULTS,以便可以让query执行多个语句。
mysql_real_connect(mySQL,serverIP,user,password,database,serverPort,NULL,CLIENT_MULTI_STATEMENTS)
当query时可能产生错误error: Commands out of sync; you can't run this command now Mysql文档中说明错误:Commands out of sync
If you get Commands out of sync; you can't run this command now in your client code, you are calling client functions in the wrong order.
This can happen, for example, if you are using mysql_use_result() and try to execute a new query before you have called mysql_free_result(). It can also happen if you try to execute two queries that return data without calling mysql_use_result() or mysql_store_result() in between. 当执行完query后,mysql将结果集放在一个result集中,产生以上问题的原因有两个:
一是未将MYSQL_RES所指对象释放,即在下次查询时要mysql_free_result();
二是结果result集不为空,这个原因比较隐蔽。解决方法可以用如下写法:
do
{
/* Process all results */
printf("total affected rows: %lld", mysql_affected_rows(mysql));
...
if (!(result= mysql_store_result(mysql)))
{
printf(stderr, "Got fatal error processing query/n");
exit();
}
process_result_set(result); /* client function */
mysql_free_result(result);
} while (!mysql_next_result(mysql));
还有个问题感觉比较奇怪,我调用一个存储过程,存储过程中就一句select
Create procedure test()
Begin
Select * from test ;
End ;
用以上方法处理结果集循环会执行两次,开始我只调了一次result= mysql_store_result(mysql)),导致以后执行query报2014错误。

最终,我为每个请求,建立一个connection,并且在使用完毕后,就主动释放。

error:2014 Commands out of sync; you can't run this command now的更多相关文章

  1. 使用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 ...

  2. 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 ...

  3. _mysql_exceptions.ProgrammingError:(2014, "commands out of sync; you can't run this command now")

    今天,测试dashboard上的一些graph, 发现,当多个graph同时向后台请求数据(异步)的时候, 出现了上述错误.而且,三个bug交替出现,另外两个bug分别是:python stop re ...

  4. mysql_query error:Commands out of sync;you can't run this command now

    MYSQL_REST *result没有释放, 用mysql_free_result(result)即可.

  5. C mysql (C API Commands out of sync; you can't run this command now)

    错误出现在当一个用户使用查询,另一个用户再使用此sql连接进行查询的时候: 原因是因为上一次使用此sql连接进行查询时没有将所有的结果集给释放掉,在所有使用此sql连接进行查询的地方将所有的结果集给释 ...

  6. Xcode10适配——Error:Multiple commands produce

    今天苹果正式推送了iOS12,今天上午就更新了最新的iOS,及Xcode10.这次更新还行,不需要我们对以前的项目紧急修复,大动手术. 用Xcode10跑之前的项目,也就报了一种类型的错误:Multi ...

  7. MySql: ”Commands out of sync“Error (Connect/C++)

    使用 Connector/C++ 查询 Mysql , 连续调用存储过程时 会出现如下: Commands out of sync; you can't run this command now,st ...

  8. GitHub 上下载代码运行报错 :'The sandbox is not sync with the Podfile.lock\'

    问题描述: github下载的Demo,很多时候使用到CocoaPods,有的时候因为依赖关系或者版本问题不能编译运行.出现例如The sandbox is not sync with the Pod ...

  9. 【故障•监听】TNS-12518、TNS-00517和 Linux Error:32:Broken pipe

    [故障|监听]TNS-12518.TNS-00517和 Linux Error:32:Broken pipe 1.1  BLOG文档结构图 1.2  前言部分 1.2.1  导读和注意事项 各位技术爱 ...

随机推荐

  1. OS memory

    https://blogs.technet.microsoft.com/askperf/2013/05/03/finally-a-windows-task-manager-performance-ta ...

  2. 基于jQuery+ashx+.net实现三级栏目联动操作

    父级ID可以为空以两个编号为一级 可以添加到第四级 table 字段有ID. name .parentNode. childNode等基本属性  selecet  parentNode  ,len(c ...

  3. Windows mobile 下读取手机SIM卡信息(转)

    Windows mobile 下读取手机SIM卡信息 c#改善 Windows mobile 下读取手机SIM卡信息

  4. redis使用日志(3):如何设置持久化

    Redis 持久化 Redis虽然是一种内存型数据库,一旦服务器进程退出,数据库的数据就会丢失,为了解决这个问题Redis提供了两种持久化的方案,将内存中的数据保存到磁盘中,避免数据的丢失. 工作目录 ...

  5. 李洪强iOS之集成极光推送二iOS 证书 设置指南

    李洪强iOS之集成极光推送二iOS 证书 设置指南 创建应用程序ID 登陆 iOS Dev Center 选择进入iOS Provisioning Portal. 在 iOS Provisioning ...

  6. GNU风格 ARM汇编语法2

    .GNU汇编程序中的标号symbol(或label) 标号只能由a-z,A-Z,-,".",_等(由点.字母.数字.下划线等组成,除局部标号外,不能以数字开头)字符组成. Symb ...

  7. Linux模块的加载和卸载

    Linux操作系统中模块操作相关命令解释lsmod  查看已经安装好的模块, 也可以查看/proc/modules文件的内容. 实际上,lsmod读命令就是通过查看/proc/modules的内容来显 ...

  8. 第一章: 当前主流的小型嵌入式 GUI

    以下内容转载自安富莱电子论坛:http://forum.armfly.com/forum.php?mod=viewthread&tid=24507&highlight=%B5%B1%C ...

  9. WP模板

    ContentControl有两个属性: // 摘要: // 获取或设置 System.Windows.Controls.ContentControl 依赖项属性的值. // // 返回结果: // ...

  10. OpenFileDialog 打开文件

    OpenFileDialog ofd = new OpenFileDialog(); ofd.Title = "选择导入的文件"; ofd.FilterIndex = 1; ofd ...