List:MySQL++« Previous MessageNext Message »
From:Ryan - SSD Van Note Date:November 13 2008 2:51pm
Subject:MySQL 5.0.67, mysql++ 2.3.2, and Rational Rose RT 7.1
View as plain text  
I have implemented an application in Rational Rose RealTime 7.1 that interfaces with a
MySQL 5.0.67 server using the mysql++ 2.3.2 API.  (We recently upgraded from MySQL 4.1
server and mysql++ 2.1.1).  First, is mysql++ 2.3.2 compatible with MySQL 5.0.67?  I saw
that mysql++ is now at 3.0.6, but the API changes will require several updates to my
application.  My application worked flawlessly with the older versions of MySQL server
and mysql++, but it lacked support for multiple results sets (needed for stored
procedures, etc.).  The upgrade to MySQL 5.0.67 appeared transparent at first, but I
quickly encountered a bug when my application failed to connect to the database server. 
The first time the connection would fail, the exception thrown by mysql++ was caught and
handled accordingly.  However, when my application tried to connect again, it crashed.  I
traced the crash down to the MySQL 5.0.67 library that my application was linking with. 
(My application is built upon the libmysql and mysqlpp DLLs.)  My application was using a
static member attribute for containing the database connection (MySqlConnection
dbConnection), and it appeared that the failed connection crash was the result of the
connection attribute not being cleaned up properly after a failed connection.  I changed
the attribute to be dynamic (MySqlConnection* dbConnection).  The connection code is now
as follows:

try
{
            databaseConnection = NULL;

            databaseConnection = new MySqlConnection();

            databaseConnection->connect(
                        rtdata->database.c_str(),
                        rtdata->hostname.c_str(),
                        rtdata->username.c_str(),
                         rtdata->password.c_str(),
                         0,
 0,
CONNECT_TIMEOUT,
0,
CLIENT_MULTI_STATEMENTS );

}

catch(MySqlConnectionFailed error)
{
            // Determine if the databaseConnection
            // handle is valid.
            if( databaseConnection )
            {
                        delete databaseConnection;
                        databaseConnection = NULL;
            }
}

The database connection is created using the default constructor because I was having
issues where the databaseConnection thought that it was already connected to the server
when I tried creating the connection with the actual connection parameters.

Database queries are wrapped in if-statement that attempts to ping the connection.  The
queries are only issued if the ping() operation returns back 0 (indicates the connection
is active).  This is now the critical issue I am facing, as the ping() operation fails
every other time I call it.  I did a test that issues 100 queries to the database, and 50
of the 100 issues failed the ping test.  I debugged the problem and found out that the
mysql_ping() call within the MySQL 5.0.67 library is what is actually failing, not
mysql++ nor my code.  Why would the ping fail every other time?  Is my database
connection becoming corrupted after each query?  Is there steps that I am missing?

The code for issuing my queries is as follows:

// Determine if database connection is alive
If(databaseConnection->ping() == 0 )
{
try
{
   MySqlQuery  query  = databaseConnection->query();

   MySqlResult result = query.store(queryString.c_str());

   if (result)
   {

      // translate/store result
            <code omitted>

      // Get remaining results, if any
      while (query.more_results())
      {
         // translate/store next result(s)
            <code omitted>
      }

   }

   else

   {

      // Some SQL queries do not return a result; nevertheless it is necessary to
      // insert a default response to inform the caller that their query succeeded.
            <code omitted>

   }

}
}

I am rather confident that I can return to the MySQL server 4.1 and get this all resolved,
but I need full support for multiple result sets with mysql++, which our version of MySQL
server 4.1 did not fully support.  Also, I want to be using the latest version of MySQL
server for performance reasons.  Could Rational Rose RT somehow be a problem?

Any help or suggestions would be greatly appreciated.

Thanks!

________________________________
This e-mail and any files transmitted with it may be proprietary and are intended solely
for the use of the individual or entity to whom they are addressed. If you have received
this e-mail in error please notify the sender.
Please note that any views or opinions presented in this e-mail are solely those of the
author and do not necessarily represent those of ITT Corporation. The recipient should
check this e-mail and any attachments for the presence of viruses. ITT accepts no
liability for any damage caused by any virus transmitted by this e-mail.

Thread
MySQL 5.0.67, mysql++ 2.3.2, and Rational Rose RT 7.1Ryan - SSD Van Note13 Nov
  • Re: MySQL 5.0.67, mysql++ 2.3.2, and Rational Rose RT 7.1Warren Young13 Nov
    • RE: MySQL 5.0.67, mysql++ 2.3.2, and Rational Rose RT 7.1Ryan - SSD Van Note13 Nov
    • RE: MySQL 5.0.67, mysql++ 2.3.2, and Rational Rose RT 7.1Ryan - SSD Van Note13 Nov
      • Re: MySQL 5.0.67, mysql++ 2.3.2, and Rational Rose RT 7.1Warren Young13 Nov
Re: MySQL 5.0.67, mysql++ 2.3.2, and Rational Rose RT 7.1Warren Young13 Nov