Jump to content

C++ mysql connection problem


Recommended Posts

  • Former Staff

Hey guys one week ago and by accident all my work have been deleted ... i manged to recover 80% of them but unfortunately i couldn't recover my FreeBSD OS ... so I've created a new topic to get some advice on "what to do next" so I've decided to compile and run the game on windows which is better environment for debugging so I've managed to compile every thing all over again now i'm stuck with a very stupid error which is :

in db/conf.txt i got those lines

 

SQL_ACCOUNT = "localhost account user pass 0"
SQL_PLAYER = "localhost player user pass 0"
SQL_COMMON = "localhost common user pass 0"
SQL_HOTBACKUP = "localhost hotbackup user pass 0"

in db/main.cpp

  if (CConfig::instance().GetValue("SQL_PLAYER", line, 256))
    {
        sscanf(line, " %s %s %s %s %d ", szAddr, szDB, szUser, szPassword, &iPort);
        sys_log(0, "Connecting to SQL_PLAYER");

        int iRetry = 5;

        do
        {
            if (CDBManager::instance().Connect(SQL_PLAYER, szAddr, iPort, szDB, szUser, szPassword))
            {
                sys_log(0, "Connected to SQL_PLAYER");
                break;
            }

            sys_log(0, "   failed, retrying in 5 seconds");
            fprintf(stderr, "   failed, retrying in 5 seconds");
            sleep(5);
        } while (iRetry--);
        fprintf(stderr, "Success PLAYER\n");
        SetPlayerDBName(szDB);
    }
    else
    {
        sys_err("SQL_PLAYER not configured");
        return false;
    }

 

SYSERR: Jul 06 10:40:49 :: CAsyncSQL::ChildLoop: AsyncSQL: query failed: Table 'account.guild' doesn't exist (query: SELECT id,name,ladder_point FROM guild  ORDER BY ladder_point DESC LIMIT 20 errno: 1146)
SYSERR: Jul 06 11:07:01 :: CAsyncSQL::ChildLoop: AsyncSQL: query failed: Table 'account.player_index' doesn't exist (query: SELECT pid1, pid2, pid3, pid4, empire FROM player_index  WHERE id=1 errno: 1146)

i can prevent this error by retyping the query but not in the way that it is suppose to be 

#update .... really weird problem i got this now 

 

AsyncSQL: query failed: Table 'common.guild' doesn't exist (query: SELECT id,name,ladder_point FROM guild  ORDER BY ladder_point DESC LIMIT 20 errno: 1146)

so now i can see the there is problem with the SQL query manager like this

CDBManager::instance().ReturnQuery(szQuery, QID_GUILD_RANKING, 0, 0); // the last parameter determines which database to enter according to this enum

enum eSQL_SLOT
{
    SQL_PLAYER,
    SQL_ACCOUNT,
    SQL_COMMON,
    SQL_HOTBACKUP,
    SQL_MAX_NUM,
};

i see that all the code are clean and right ... but the query are entering a random database as i can see

 

sorry for my bad english

Flygun

 

 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

  • Former Staff
            if (CDBManager::instance().Connect(SQL_PLAYER, szAddr, iPort, "player", szUser, szPassword))
            {
                sys_log(0, "Connected to SQL_PLAYER");
                break;
            }

guild table must be in player ... the problem is that the SQL Manager puts a random database name

query failed: Table 'account.guild' doesn't exist 
query failed: Table 'common.guild' doesn't exist

see? and it not account or common it must be "player"

i've got a temp fix like this

            if (CDBManager::instance().Connect(SQL_PLAYER, szAddr, iPort, "player", szUser, szPassword))
            {
                sys_log(0, "Connected to SQL_PLAYER");
                break;
            }
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.