CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Lost connection to MySQL server during query error

  1. #1
    Join Date
    Mar 2010
    Posts
    74

    Lost connection to MySQL server during query error

    Hello,
    I am developing MySQL client using libmysql.dll
    I have insert records from queue on time based approach.

    I am using thread :
    DWORD WINAPI database_worker::InsertThread(LPVOID lpParam)
    {
    database_worker *pthis = static_cast<database_worker*>(lpParam);

    string Insert;
    while(pthis->_bInsertThread && !pthis->_bShutDown)
    {
    WaitForSingleObject(pthis->_insert_queue.m_hEvent,3000);
    while(pthis->_insert_queue.Size() > 0 && pthis->_bInsertThread && !pthis->_bShutDown)
    {
    Insert = pthis->_insert_queue.Pop();
    pthis->exec_query(&Insert);
    }
    }

    return 0;
    }

    exec_query method contains call to mysql_query(&_sql_client->_MySQL, Insert->c_str()),
    errors checkups etc.
    Application fails in exec_query with error messages:

    database_worker::exec_query : mysql - [2013], Lost connection to MySQL server during query
    mysql - [2006], MySQL server has gone away
    mysql - [2006], MySQL server has gone away

    There are a lot of reasons for - [2013], Lost connection to MySQL server during query
    but there " timeout and packet_size issue" is not my case.
    Queries are correct, the same queries complete successfully when I call "exec_query" not from thread..
    This is misterious thing, ghave you any opinion?
    Thanks a lot

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,277

    Re: Lost connection to MySQL server during query error

    Is the MySql library threadsafe?

  3. #3
    Join Date
    Mar 2010
    Posts
    74

    Re: Lost connection to MySQL server during query error

    Hmm..may be I need threadsafe libmysql_r library .
    It is necessary check
    Thanks for prompt1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)