Quantcast
Channel: MySQL Forums - Connector/C++
Viewing all articles
Browse latest Browse all 527

C++ Connector crashes if SQL server is not reachable. Works fine otherwise (no replies)

$
0
0
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);
}

Viewing all articles
Browse latest Browse all 527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>