Results 1 to 2 of 2

Thread: MyLibrary loading mysql driver related problem

  1. #1
    Join Date
    Sep 2010
    Location
    Poland
    Posts
    112
    Thanks
    8
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default MyLibrary loading mysql driver related problem

    I have written my own library to separate strictly database job from main application code, library will be pretty vital for whole application to work, but I encountered a little problem which beyond obvious solution I can not solve.

    The problem lies is loading the driver for mysql. Driver not loads, as QCoreApplicationmust be initialized before I could even have tried to load any driver. Well ok, but I dragged to my library whole class which wraps connection data, opens the database and than safely closes it.

    Is there any other solution, apart from loading the driver back in main application, where QCoreApplication is initialized ?

    I moved loading the driver back to my application code, than I tried
    - to pass to library connection name -> with no success, db is not opening
    - to pass to library whole QSqlDatabase object, or pointer, or reference, db is opening, but every next method in library which requires access to db returns that db is closed

    I am starting to think that only option left here is to move whole connection establishment job back to my application code, but I am thinking... is this not thread problem. I mean application is another thread and library is another, so perhaps driver loaded in one thread can not be reused in another ?
    Last edited by kornicameister; 19th August 2011 at 11:03. Reason: updated contents
    My schedule makes my cry
    My works makes my laugh
    My life makes... oh...no....

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: MyLibrary loading mysql driver related problem

    I don't see where the problem is.
    Just don't make the connection to the database when you load your lib, rather, make a call from your application to the lib, to connect to the database.
    This will have to be after QCoreApplication has been initialized.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. MySql driver problem
    By stilgar in forum Qt Programming
    Replies: 1
    Last Post: 13th April 2010, 10:26
  2. Mysql plug in loading problem
    By addu in forum Qt Programming
    Replies: 0
    Last Post: 29th September 2009, 11:14
  3. MySQL driver - Very strange problem. PLEASE HELP ME. Thanks.
    By diego in forum Installation and Deployment
    Replies: 0
    Last Post: 2nd June 2009, 01:56
  4. Error Loading MySql Driver in 4.3.4
    By perrigo in forum Qt Programming
    Replies: 5
    Last Post: 26th March 2008, 14:38
  5. Qt4 and mysql(driver problem)
    By knut in forum Installation and Deployment
    Replies: 20
    Last Post: 27th December 2007, 14:47

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.