MySQL Forums
Forum List  »  Connector/C++

Re: C++ Connector crashes if SQL server is not reachable. Works fine otherwise
Posted by: Andrei Khaidurov
Date: July 19, 2013 06:58AM

Nothing to do with the connector. My own silly mistake and horrible debugging.

Working code:

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 %s\r\n\nERR:%s",e.getErrorCode(),e.getSQLState().c_str(),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 %s\r\n\nERR:%s",e.getErrorCode(),e.getSQLState().c_str(),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
Re: C++ Connector crashes if SQL server is not reachable. Works fine otherwise
1989
July 19, 2013 06:58AM


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.