[問題] c++ sql_query failed
開發平台(Platform): Linux using CodeBlocks
額外使用到的函數庫(Library Used): MySQL library
問題(Question):我用c++ 使用 sql_query() 丟 double 讓他增加到sql table上
below is my code
--------------------
bool mysqlinsert(double sqlinput){
MYSQL *conn_ptr;
conn_ptr = mysql_init(NULL);
if(!conn_ptr)
{
fprintf(stderr,"mysql_init failed\n");
//return EXIT_FAILURE;
}
conn_ptr =
mysql_real_connect(conn_ptr,"localhost","root","nlpgroup","testdb",0,NULL,0);
if(conn_ptr){
int abc;
char sql_buffer[64] = {0};
sprintf(sql_buffer,"insert into EM1 (Prob) values(\"%f\")",sqlinput);
if((abc = mysql_query(conn_ptr,sql_buffer)))
{
printf("error code:%s\n",mysql_error(conn_ptr));
}
mysql_close(conn_ptr);
return true;
//connection succees
}
else
printf("Connection failed\n");
mysql_close(conn_ptr);
return false;
//return EXIT_SUCCESS;
}
--------------------------------
問題重點一開始還可以成功丟入也成功增加進入sql table 中
到一個數量之後 -> connection failed
想到可能是sql query 可能有限制次數 哪邊可調這些設定?(on Linux)
**這些query 可能會達幾萬次
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 163.22.21.92
※ 文章網址: http://www.ptt.cc/bbs/C_and_CPP/M.1405503419.A.57D.html
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章