MySQL Forums
Forum List  »  Connector/C++

C++ Connector crashes if SQL server is not reachable. Works fine otherwise
Posted by: Andrei Khaidurov
Date: July 08, 2013 07:41PM

Windows 32 bit. C++ connector 1.1.3
Connector works fine if MySQL is reachable (either local or remote), but crashes (both in debug and release build) if it is not reachable. I have tried compiling connector with my compiler (VS2008) - the same result.

It works fine in console application, but not from my native C++ application. Code is virtually the same standard example code from documentation.

Here it is:

try
{
/* Create a connection */
driver = get_driver_instance();
}
catch (sql::SQLException &e)
{
StringCchPrintfA(szQry,sizeof(szQry), "SQLException occured! Can't get driver instance. \r\n\nMySQL error code %d\r\n\nSQLState %d\r\n\nERR:%s",e.getErrorCode(),e.getSQLState(),e.what());
MessageBoxA(NULL,szQry,"SWI Marxman: SQL ERROR" ,MB_ICONEXCLAMATION|MB_OK);
}

try
{
/* try to connect */
con = driver->connect(szConnStr, szUser, szPassword);
}
catch (sql::SQLException &e)
{
StringCchPrintfA(szQry,sizeof(szQry), "SQLException occured! Can't connect to MySQL. \r\n\nMySQL error code %d\r\n\nSQLState %d\r\n\nERR:%s",e.getErrorCode(),e.getSQLState(),e.what());
MessageBoxA(NULL,szQry,"MyAPP: SQL ERROR" ,MB_ICONEXCLAMATION|MB_OK);
}
catch (std::runtime_error &e)
{
StringCchPrintfA(szQry,sizeof(szQry), "Run-time error! Can't connect to MySQL. \r\n\nERROR:%s",e.what());
MessageBoxA(NULL,szQry,"MyAPP: SQL CONNECT ERROR" ,MB_ICONEXCLAMATION|MB_OK);
}

Options: ReplyQuote


Subject
Views
Written By
Posted
C++ Connector crashes if SQL server is not reachable. Works fine otherwise
3582
July 08, 2013 07:41PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.