[Qt-interest] Inherit a MYSQL object.
David Villalobos Cambronero
david.villalobos.c at gmail.com
Fri Aug 27 16:51:56 CEST 2010
Hi all, me again, now I'm trying to learn how to make MySQL connection using
mysql.h, I know is better to use the QSqlDatabase, but right now I want to
learn how to make with mysql.h
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
I have a parentClass, int this class I declare as public a MYSQL *object:
#include "mysql/mysql.h"
#include "stdio.h"
class parentClass
{
public:
mysqlTopClass();
doSomeQuery();
MYSQL *mysqlConnection;
};
Then I have a childClass that inherits from parentClass, in this class
Iinstantiatethe mysqlConnection
childClass::mysql(QString UserName, QString HostName, QString password,
QString database)
{
mysql_real_connect(mysqlConnection, HostName.toAscii().data(),
UserName.toAscii().data()
, password.toAscii().data(), database.toAscii().data(),
3306, NULL, 0);
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
I can successfully make the connection with MySQL, so far, everything is
going fine.
The problem comes when I try to use the instantiated the mysqlConnection in
doSomeQuery(), the program extis with a Segmentation fault, the gdb says:
Program received signal SIGSEGV, Segmentation fault.
0xb7e958d7 in mysql_send_query () from /usr/lib/libmysqlclient.so.16
Here is the deal, I have a public MYSQL Object in mysqlTopClass, I instantiate
it in childClass (I prove that at that moment everything is working) and try
to use the instantiated object in parentClass with doSomeQuery().
Any idea?
What I'm doing wrong?
Best regards and thanks for your comments.
Regards
---
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100827/41b9e2b4/attachment.html
More information about the Qt-interest-old
mailing list