Results 1 to 4 of 4

Thread: Accessing MySQL DB from application fired from Java application

  1. #1
    Join Date
    Dec 2010
    Posts
    35
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Accessing MySQL DB from application fired from Java application

    I have a Qt 4.7.0-based application working on both Linux (FC 13) n Windows Vista accessing a MySQL database. The Qt application connects to a MySQL database and reads some data. Everything works well when I fire the Qt application from my development IDE or installation structure on both Linux and Windows Vista.

    However, in production I will be starting my Qt application from a Java (Eclipse RCP)-based application. The Java app fires the Qt app in a separate (Java application) thread as users can continue to use both applications at the same time.
    Qt Code:
    1. Runtime rt = Runtime.getRuntime();
    2. Process proc = rt.exec(cmdList.toArray(new String[]{}),envList.toArray(new String[]{}));
    To copy to clipboard, switch view to plain text mode 

    This all works well when everything is running on Linux. However, when I start the Qt application from the Java application on Windows Vista, I get the following error:
    Qt Code:
    1. Can't create TCP/IP socket (10106) QMYSQL: Unable to connect
    To copy to clipboard, switch view to plain text mode 
    I don't understand why starting the Qt app from within the Java app would cause a problem....

    According to the MSDN doc, error 10106 is:
    Qt Code:
    1. WSAEPROVIDERFAILEDINIT - Service provider failed to initialize.
    2.  
    3. The requested service provider could not be loaded or initialized. This error is returned if either a
    4. service provider's DLL could not be loaded (LoadLibrary failed) or the provider's WSPStartup or
    5. NSPStartup function failed.
    To copy to clipboard, switch view to plain text mode 
    Yes, I call WSAStartup() before I open the database...

    Ideas?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Accessing MySQL DB from application fired from Java application

    The environment that your Java application is providing to the Qt app probably does not include one or more DLLs necessary to connect to the MySql database. They should be in the PATH or current working directory (make sure this is what you think it is). Given the error message I would assume that it is the MySQL lib that is not being found rather than the Qt Mysql plugin.

  3. #3
    Join Date
    Dec 2010
    Posts
    35
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Accessing MySQL DB from application fired from Java application

    I think you're correct with the fact that the application is not finding some DLL when launched from Java. I do have the MySQL library directory in the PATH (C:\Programs\MySQL\MySQLServer5.1\lib\opt) as well as the Qt plugins directory (C:\Programs\Qt\4.7.0\plugins\sqldriver) so I don't think those are the missing DLLs.

    I'm running the application using Depends (as described in http://msdn.microsoft.com/en-us/libr...=VS.90%29.aspx). A little hokey to run, but....

    The application is now failing with an access violation in MSVCR90D.DLL. MSVCR90D is indeed loaded. I scanned the Depends output and found the load of that library.

    The end of the run (in Depends) says:

    Qt Code:
    1. LoadLibraryW("uxtheme") called from "QTCORED4.DLL" at address 0x671AB7A3.
    2. LoadLibraryW("uxtheme") returned 0x750D0000.
    3. GetProcAddress(0x750D0000 [UXTHEME.DLL], "EndPanningFeedback") called from "QTCORED4.DLL" at address 0x671ABD78 and returned NULL. Error: The specified procedure could not be found (127).
    4. LoadLibraryW("user32") called from "QTCORED4.DLL" at address 0x671AB7A3.
    5. LoadLibraryW("user32") returned 0x767D0000.
    6. GetProcAddress(0x767D0000 [USER32.DLL], "RegisterTouchWindow") called from "QTCORED4.DLL" at address 0x671ABD78 and returned NULL. Error: The specified procedure could not be found (127).
    7. GetProcAddress(0x767D0000 [USER32.DLL], "GetTouchInputInfo") called from "QTCORED4.DLL" at address 0x671ABD78 and returned NULL. Error: The specified procedure could not be found (127).
    8. GetProcAddress(0x767D0000 [USER32.DLL], "CloseTouchInputHandle") called from "QTCORED4.DLL" at address 0x671ABD78 and returned NULL. Error: The specified procedure could not be found (127).
    9. Second chance exception 0xC0000005 (Access Violation) occurred in "MSVCR90D.DLL" at address 0x6378F8BC.
    10. Exited "TRAINERTOOL.EXE" (process 0x43C) with code -1073741819 (0xC0000005).
    To copy to clipboard, switch view to plain text mode 

    There's 11 'GetProcAddress()' failures at the end of the run. I just showed 4 above.

    Also, Depends complains that 'wintab32.dll' is missing. I'm not sure I need that, do I?!?

    Also, also, I ran 'dumpbin /dependents' on my application using the same PATH as I used when I ran it with Depends and it responded with:

    Qt Code:
    1. Dump of file trainerTool.exe
    2.  
    3. File Type: EXECUTABLE IMAGE
    4.  
    5. Image has the following dependencies:
    6.  
    7. log4cxx.dll
    8. model.dll
    9. flowEngine.dll
    10. QtGuid4.dll
    11. QtCored4.dll
    12. MSVCP90D.dll
    13. MSVCR90D.dll
    14. KERNEL32.dll
    15.  
    16. Summary
    17.  
    18. 2000 .data
    19. 11000 .idata
    20. 20000 .rdata
    21. 1000 .rsrc
    22. 46000 .text
    To copy to clipboard, switch view to plain text mode 
    I checked and all of the referenced DLLs above are loaded (when using Depends).

    Still searching....
    Last edited by redBeard; 15th July 2011 at 22:56.

  4. #4
    Join Date
    Dec 2010
    Posts
    35
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Accessing MySQL DB from application fired from Java application

    Well, I reeeeeeally had to resolve this issue and I figgered it out....

    The Qt MySQL layer uses the MySQL 'client' layer which tries to create a socket to the server. This socket() call was failing with the 10106 error code.

    Turns out the Windblows socket library requires the SYSTEMROOT environment variable to be set in order to work. When I was launching the Qt-based application from Java, I was not setting that variable, I wanted to just set what I thought I needed - didn't think I needed that one...

    This variable is normally set in cmd shells to C:\Windows. I just didn't set it in my Java ProcessBuilder variable map.

    Problem solved.

Similar Threads

  1. Replies: 2
    Last Post: 15th April 2011, 11:33
  2. Accessing system info on Maemo Nokia N900 device in Qt application
    By freely in forum Qt for Embedded and Mobile
    Replies: 6
    Last Post: 2nd April 2011, 23:10
  3. First application with mysql
    By miroslavgojic in forum Newbie
    Replies: 0
    Last Post: 19th July 2010, 22:18
  4. deploying application with mysql
    By addu in forum Qt Programming
    Replies: 10
    Last Post: 4th October 2009, 11:02
  5. accessing my main application window widget
    By jayw710 in forum Newbie
    Replies: 8
    Last Post: 15th November 2007, 20:33

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.