When the application crashes, the MySQL database opens

Im using Qt 5.0.0 on Windows 7 × 64 (personal compiler is MinGW x64). I added support for MySQL in the settings, as well as MySQL installed in the system. MySQL libraries, headers and visible in the application.

Program crashes when opening a database. I open the database as follows:

QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setDatabaseName("My DB name");
db.setUserName("root");
db.setPassword("My password");
db.setHostName("localhost");
db.setPort(3306);
try{
db.open(); // <=== Crashes without throwing an exception
}
catch(std::exception e)
{
    std::cout << e.what() << std::endl;
}

Notes:

qDebug() << QSqlDatabase::drivers();

prints

("QMYSQL3", "QMYSQL", "QODBC3", "QODBC", "QSQLITE")

The signature of the problem generated by the operating system is as follows:

Problem Event Name: APPCRASH
Application Name: CMS.exe
Application Version: 0.0.0.0
Application Timestamp: 51010cdd
Fault Module Name: Qt5Sql.dll
Fault Module Version: 5.0.0.0
Fault Module Timestamp: 50f6b734
Exception Code: c0000005
Exception Offset: 00000000000df950
OS Version: 6.1.7600.2.0.0.256.1
Locale ID: 1033
Additional Information 1: db69
Additional Information 2: db697f824a06df6631cf05ed1f197e16
Additional Information 3: 1d76
Additional Information 4: 1d7605bf295c1c2cfcbfc6bfcec7c569

I am generating a .a file using gendef and dlltool as follows:

gendef libmysql.dll
dlltool --input-def libmysql.def --dllname libmysql.dll --output-lib libmysql.a

Qt is configured with -qt-sql-mysql, rather than -plugin-sql-mysql. (What is the difference?)

+5
source share
1 answer

, ( , ), , try.

'db' try-catch ( ).

+1

All Articles