[Qt-interest] loading sql plug in

Yuvaraj R yuvaraj at ongobiz.com
Wed Sep 30 08:23:46 CEST 2009


Thanks for your reply

Already i have downloaded the Mysql and MIngw

and i created the libmysql.a with help mingw..

I added libmysql.dll in Qt bin folder...
If you wish to deploy your program to another computer where these libraries
are not installed, you need to place them in the following paths: *
<APPDIR>\libmysql.dll*
*<APPDIR>\sqldrivers\qsqlmysql.dll


I want to use my program another computer..That's why i added.. What is the
problem here.. Even i could not able to open mysql  ..


Please Help me


Thanks

Yuvaraj R
*


On Wed, Sep 30, 2009 at 11:44 AM, Robert Escott <robert at binarylogic.co.za>wrote:

>  Hi Yuvaraj
>
> You didn't read the instructions properly.
>
> Firstly, the library path for MySQL is not part of Qt, it's the location
> where you put the SDK that you downloaded from MySQL itself. It will
> probably be something like
>
> c:\MySQL\MySQL Server 5.0.1\lib\opt
>
> Secondly, nowhere did I say you must add the MySQL dll OR the plugin dll to
> the project file. You must not. They get loaded automatically when you run
> your program.
>
> Robert
>
> ----- Original Message -----
> *From:* Yuvaraj R <yuvaraj at ongobiz.com>
> *To:* Robert Escott <robert at binarylogic.co.za>
> *Cc:* qt-interest at trolltech.com
> *Sent:* Wednesday, September 30, 2009 7:30 AM
> *Subject:* Re: [Qt-interest] loading sql plug in
>
> Thanks Robert
>
> I have done as per you..
>
> My .pro file
>
> LIBS += -L../pjproject-1.0.2/pjlib/lib \
>
> -L../pjproject-1.0.2/pjlib-util/lib \
>
> -L../pjproject-1.0.2/pjnath/lib \
>
> -L../pjproject-1.0.2/pjmedia/lib \
>
> -L../pjproject-1.0.2/pjsip/lib \
>
> -L../pjproject-1.0.2/third_party/lib \
>
> -L../database
>
> LIBS+=C:/Qt/2009.01/bin/lib/opt   -llibmysql
>
> LIBS+=C:/Qt/2009.01/qt/plugins/sqldrivers  -llqsqlmysql
>
>
> But i am getting
>
> :/Qt/2009.01/bin/lib/opt: No such file: Permission denied
>
> collect2: ld returned 1 exit status
>
>
> and i could not able to open my sql database
>
> main.cpp
> #include <QSqlDatabase>
>
> #include <QVector>
>
> #include <QStringList>
>
> #include <QSqlDatabase>
>
> int main(int argc, char *argv[])
>
> {
>
> QApplication a(argc, argv);
>
> QStringList list = QSqlDatabase::drivers();
>
> for(int i=0;i<list.size();i++)
>
> {
>
> qDebug() << list.at(i);
>
> }
>
> if(!createConnection())
>
> {
>
> return 1;
>
> }
>
> login w;
>
> w.show();
>
> return a.exec();
>
> }
>
> connection.h
> #include <QSqlDatabase>
>
> #include <QSqlError>
>
> #include <QSqlQuery>
>
> static bool createConnection()
>
> {
>
> QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
>
> db.setDatabaseName("Addu");
>
> db.setHostName("localhost");
>
> db.setUserName("root");
>
> db.setPassword("root");
>
> if (!db.open()) {
>
> QMessageBox::critical(0, qApp->tr("Cannot open database"),
>
> qApp->tr("Unable to establish a database connection.\n"
>
> "This example needs SQLite support. Please read "
>
> "the Qt SQL driver documentation for information how "
>
> "to build it.\n\n"
>
> "Click Cancel to exit."), QMessageBox::Cancel);
>
> return false;
>
> }
>
> return true;
>
> }
>
>
> Please help me
>
> I am struggling with 2 days .. I want to use database in other systems also
>
>
> Thanks
>
> Yuvaraj R
>
> On Tue, Sep 29, 2009 at 11:48 PM, Robert Escott <robert at binarylogic.co.za>wrote:
>
>>  I don't understand why you're creating macros inside your project.
>>
>> I had problems initially when I wanted to use MySQL as well. There are a
>> few things you should do before you can successfully connect to the
>> database:
>>
>> 1) Qt doesn't come with the plugin already made, it only has the wrapper
>> code needed to create the plugin. The project for this is found in <*
>> QTDIR>\src\plugins\sqldrivers\mysql.* The instructions for creating the
>> plugin can be read at
>> http://doc.trolltech.com/4.5/sql-driver.html#how-to-build-the-qmysql-plugin-on-windowsand will result in a file called
>> *qsqlmysql.dll* being created and placed in <*QTDIR>\plugins\sqldrivers*.
>>
>>
>> 2) The plugin itself is only an adapter between the QtSql module and the
>> actual MySQL library. To use the plugin, you need to copy the MySQL library
>> to your *<QTDIR>\bin* directory. The file you're looking for is *
>> libmysql.dll* and can be found in your <*MYSQL>\lib\opt* directory.
>>
>> 3) If you wish to deploy your program to another computer where these
>> libraries are not installed, you need to place them in the following paths:
>> *<APPDIR>\libmysql.dll*
>> *<APPDIR>\sqldrivers\qsqlmysql.dll*
>>
>> Once you've done the above, you don't even have to think about loading and
>> unloading the plugin from your code, you just go right ahead.
>>
>> *#include <QSqlDatabase>*
>> **
>> *int main(int argc, char **argv){*
>> **
>> *   QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");*
>> *   db.setDatabaseName("Addu");*
>> *   db.setHoseName("localhost");*
>> *   db.setPort(-1);*
>> *   db.setUserName("root");*
>> *   db.setPassword("");*
>> *   if (!db.open())*
>> *      return -1;*
>> **
>> *   return 0;*
>> *}*
>>
>> That's all. You don't even have to think about the plugin in your code.
>>
>> I hope this solves your problem.
>>
>> Robert
>>
>> ----- Original Message -----
>>  *From:* Yuvaraj R <yuvaraj at ongobiz.com>
>> *To:* qt-interest at trolltech.com
>> *Cc:* Thiago Macieira <thiago.macieira at trolltech.com>
>> *Sent:* Tuesday, September 29, 2009 1:27 PM
>> *Subject:* Re: [Qt-interest] loading sql plug in
>>
>> I resolved the my previous error...
>>
>> Now i am facing new error,
>>
>> error is
>>
>>   qt_plugin_instance_qsqlmysql()what's is there previous mentioned  code
>>
>> please help me
>>
>>
>> Thanks
>>
>> Yuvaraj R
>> On Tue, Sep 29, 2009 at 1:22 PM, Yuvaraj R <yuvaraj at ongobiz.com> wrote:
>>
>>> Hi All place the Sql folder outside of project..It contains following
>>> files
>>>
>>> 1) qsqlmysql
>>>
>>> 2)libqsqlmysql4.a
>>>
>>> My  .pro file is
>>>
>>> TARGET = MaxxTel
>>>
>>> TEMPLATE = app
>>>
>>> QT += core \
>>>
>>> gui \
>>>
>>> xml \
>>>
>>> network
>>>
>>> QT += sql
>>>
>>> QTPLUGIN += qsqlmysql
>>>
>>> SOURCES += main.cpp \
>>>
>>> mainwindow.cpp \
>>>
>>> widget1.cpp \
>>>
>>> pjcallback.cpp \
>>>
>>> buddy.cpp \
>>>
>>> form.cpp \
>>>
>>> setting_form.cpp \
>>>
>>> treewidget_override.cpp \
>>>
>>> registration_form.cpp \
>>>
>>> conference.cpp \
>>>
>>> tab_widget.cpp \
>>>
>>> window_alert.cpp \
>>>
>>> text_edit1.cpp \
>>>
>>> style_sheet.cpp \
>>>
>>> line_edit.cpp \
>>>
>>> string_new.cpp \
>>>
>>> login.cpp \
>>>
>>> create_database.cpp \
>>>
>>> history_call.cpp
>>>
>>> HEADERS += mainwindow.h \
>>>
>>> widget1.h \
>>>
>>> pjcallback.h \
>>>
>>> buddy.h \
>>>
>>> form.h \
>>>
>>> setting_form.h \
>>>
>>> treewidget_override.h \
>>>
>>> registration_form.h \
>>>
>>> conference.h \
>>>
>>> tab_widget.h \
>>>
>>> window_alert.h \
>>>
>>> text_edit1.h \
>>>
>>> style_sheet.h \
>>>
>>> line_edit.h \
>>>
>>> string_new.h \
>>>
>>> login.h \
>>>
>>> create_database.h \
>>>
>>> ../connection.h \
>>>
>>> history_call.h
>>>
>>> FORMS += mainwindow.ui \
>>>
>>> widget1.ui \
>>>
>>> form.ui \
>>>
>>> setting_form.ui \
>>>
>>> registration_form.ui \
>>>
>>> window_alert.ui \
>>>
>>> login.ui \
>>>
>>> conference.ui
>>>
>>> INCLUDEPATH += ../pjproject-1.0.2/pjlib/include \
>>>
>>> ../pjproject-1.0.2/pjlib-util/include \
>>>
>>> ../pjproject-1.0.2/pjnath/include \
>>>
>>> ../pjproject-1.0.2/pjmedia/include \
>>>
>>> ../pjproject-1.0.2/pjsip/include
>>>
>>> LIBS += -L../pjproject-1.0.2/pjlib/lib \
>>>
>>> -L../pjproject-1.0.2/pjlib-util/lib \
>>>
>>> -L../pjproject-1.0.2/pjnath/lib \
>>>
>>> -L../pjproject-1.0.2/pjmedia/lib \
>>>
>>> -L../pjproject-1.0.2/pjsip/lib \
>>>
>>> -L../pjproject-1.0.2/third_party/lib \
>>>
>>> -L../Sql
>>>
>>> RESOURCES += image.qrc
>>>
>>> win32-g++:LIBS += -L../openssl-0.9.8g
>>>
>>> win32-g++:LIBS += -lpjsua-i686-pc-mingw32 \
>>>
>>> -lpjsip-ua-i686-pc-mingw32 \
>>>
>>> -lpjsip-simple-i686-pc-mingw32 \
>>>
>>> -lpjsip-i686-pc-mingw32 \
>>>
>>> -lpjmedia-codec-i686-pc-mingw32 \
>>>
>>> -lpjmedia-i686-pc-mingw32 \
>>>
>>> -lpjnath-i686-pc-mingw32 \
>>>
>>> -lpjlib-util-i686-pc-mingw32 \
>>>
>>> -lpj-i686-pc-mingw32 \
>>>
>>> -lportaudio-i686-pc-mingw32 \
>>>
>>> -lgsmcodec-i686-pc-mingw32 \
>>>
>>> -lilbccodec-i686-pc-mingw32 \
>>>
>>> -lspeex-i686-pc-mingw32 \
>>>
>>> -lresample-i686-pc-mingw32 \
>>>
>>> -lmilenage-i686-pc-mingw32 \
>>>
>>> -lsrtp-i686-pc-mingw32 \
>>>
>>> -lm \
>>>
>>> -lwinmm \
>>>
>>> -lole32 \
>>>
>>> -lws2_32 \
>>>
>>> -lwsock32 \
>>>
>>> -lqsqlmysql
>>>
>>>
>>> when i am trying to build ,i am getting following error
>>>
>>>
>>> cannot find -lqsqlmysql
>>>
>>>
>>>
>>> Please help me to load the mysql plug in to my project
>>>
>>>
>>>
>>> Thanks
>>>
>>>
>>> Yuvaraj R
>>>
>>>
>>>
>>>
>>>
>>> On Tue, Sep 29, 2009 at 11:17 AM, Yuvaraj R <yuvaraj at ongobiz.com> wrote:
>>>
>>>> Thanks for your reply
>>>>
>>>> I realized my mistake..
>>>>
>>>> still i didn't load the plug in
>>>>
>>>> i place sql folder in my project and inserted the created qsqlmysql.dll
>>>> in folder..
>>>>
>>>> in pro file
>>>>
>>>> LIBS += -L../sql
>>>>
>>>> In my main function i used following macro
>>>>
>>>> Q_IMPORT_PLUGIN(qsqlmysql)
>>>>
>>>> but i am getting following error.
>>>>
>>>>
>>>>
>>>>  error: undefined reference to `qt_plugin_instance_qsqlmysql()'
>>>>
>>>>
>>>> Thanks
>>>>
>>>> Yuvaraj R
>>>>
>>>>
>>>> Then i added in my pro file ..
>>>>
>>>> On Tue, Sep 29, 2009 at 11:07 AM, Christopher Rasch-Olsen Raa <
>>>> christopher at technophile.info> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> What does the plugin-system say? Does your plugin get loaded? If so,
>>>>> what does
>>>>> the errors you get when loading a database say? Without this
>>>>> information is
>>>>> _really_ hard for us to help.
>>>>>
>>>>> --
>>>>> Christopher
>>>>>
>>>>> On Tuesday 29 September 2009 07:31:14 Yuvaraj R wrote:
>>>>> > Hi All
>>>>> >
>>>>> >  I created the sql plug in .
>>>>> >
>>>>> > I tried with
>>>>> >
>>>>> >
>>>>> > QSqlDatabase db = QSqlDatabase::addDatabase("Mysql");
>>>>> >
>>>>> > db.setDatabaseName("Addu");
>>>>> >
>>>>> > but i am getting error..
>>>>> >
>>>>> > how do i use the plugin in my project and upload to project.
>>>>> >
>>>>> > please help me
>>>>> >
>>>>> > can anybody provide me a useful links
>>>>> >
>>>>> > Thanks
>>>>> >
>>>>> > Yuvaraj R
>>>>> >
>>>>> _______________________________________________
>>>>> Qt-interest mailing list
>>>>> Qt-interest at trolltech.com
>>>>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>>>>
>>>>
>>>>
>>>
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090930/6f063059/attachment.html 


More information about the Qt-interest-old mailing list