MySQL Driver not loaded on Qt - mysql

Trying to connect to MySQL using
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
gives me the
Driver not loaded error
Reading the other questions and answers did not help me because they have qt4 instead of 5 that I am using, and they had to build the drivers themselves. I do have the drivers though
And I also did load the path in the pro file here
So why is this happening? Should I try and compile the drivers myself as suggested in some other questions?
EDIT
I also did make sure to use MySQL 32bit.

In Debug Mode on development machine the Qt-Framework Installation is enough.
In Release Mode you will have to provide the required driver in the sqldrivers-folder located in your working directory: $(wcd)/sqldrivers/*
Edit:
Check output of: QSqlDatabase::drivers () Eventually rebuild sql drivers for your system using $QTDIR/src/plugins/sqldrivers/mysql/mysql.pro.
Also try adding mysql-client-library to your working directory directly or setting up a library path to look for. It is not enough to add INCLUDEPATH / LIB in pro file, since this is for compile/link time only. During runtime the executable looks in the known places (typical windows: $WINDIR/system32/;$PATH;...)

Related

MySQL++ Application error at launch

I compiled MySQL++ with no issues. When I launched some of the executables (resetdb.exe and simple1.exe) they suggest to run to test if the installation has been successful, the first error I got was that libmysql.dll was missing.
Adding its path to the PATH environment variable did not fix the problem, even after launching a new command prompt; I had to copy the DLL in the directory where MySQL++ executables are.
Now the DLL is found, but I get this error:
simple1.exe - Application error
The application was unable to start correctly (0xc000007b).
Click OK to close the application.
even launching from the command line, I get no more information than these.
Thank you for any help!
MySQL 5.5 -
MySQL++ 3.0.9 -
Windows 7 64 bits -
MINGW32 -
GCC 4.4.0
0xC000007B is a Windows error that means the executable is corrupted. It could refer either to simple1.exe or to one of the DLLs it's linking against.
Some reasons this could happen:
You're mixing toolchains in an incompatible way. In your case, you may have built simple1.exe using pieces built by MinGW GCC and pieces built by Visual C++. MinGW should be compatible with any pure C DLL built by Visual C++, including the MySQL C API DLL. However, you may have other pieces interfering. MinGW isn't compatible with VC++ at the C++ level, but then, it shouldn't have linked at all if this were your problem.
You didn't follow the MySQL C API import library build steps in README-MinGW.txt. You either missed a step, or skipped it entirely and are trying to use the import library that shipped with MySQL.
In your previous gyrations, you ended up with a corrupt object file, which got linked in. Try saying make clean all at the top level of MySQL++ to force a complete rebuild.
You're mixing versions of MySQL or MySQL++. If you have more than one version of each on the system, make sure you're consistent in their use. That is, build the C API import library from the same DLL you run the programs against, use exrun.bat to run the examples to ensure you're using the just-built version of the MySQL++ DLL instead of another you have in your PATH, etc.
Additionally, I note that you're using an older version of MySQL++. If you were on Linux, I could understand that as some distributions still ship with 3.0.9. But since you have to build MySQL++ from source with MinGW, I don't see why you're not using 3.1.0. Did you get a binary build from somewhere?
As for your PATH problem, did you restart the MinGW shell after doing this? PATH updates don't affect running programs; they keep the value they saw when they started.

Matlab R2010b setting up MySql

I'm trying to setting up a mySql connection using Matlab, I have read I few tutorial but unfortunately I can't get work of them. I had tried to compile the source(.cpp) but I got the following error:
Error: Could not detect a compiler on local system
which can compile the specified input file(s)
C:\PROGRA~1\MATLAB\R2010B\BIN\MEX.PL: Error: No compiler options file could be found to compile source code. Please run "mex -setup" to rectify.
So I I typed "mex -setup"
Please choose your compiler for building external interface (MEX) files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[0] None
Compiler:
but there is no compiler.
Anybody can help me, how can I make a connection between matlab and mysql, I'm using windows 7 64 bit and Matlab 2010b.
I already installed wampserver.
Have you tried to establish MySQL connection from MATLAB using JBCC connector?
I did it successfully and put the complete workflow with the code example (requires Database Toolbox) in this question:
connection of MATLAB 7.0 and MYSQL
Haven't try on 64-bit though. Please let me know if it will fail.
UPDATE
You can also try the following submissions to File Exchange that do not require the Database toolbox:
queryMySQL
Access a MySQL database
I'm guessing you installed Matlab 64-bit as well, which does NOT come with a built-in MEX compiler (32-bit version uses lcc). You have a few options, but the easiest is to install Visual C++ Express (it's free! http://www.microsoft.com/express/Windows/) which will give you a 64-bit compatible compiler in the mex -setup listing. You'll have to double check which versions of the compiler 2010b is compatible with though.
Caveat: I tried this once and couldn't get it to work, but it was with like 2007b or something, and I didn't try that hard, I just installed 32-bit Matlab.

Using MySQL in R for Windows

How to use MySQL in R (statistic language) for Windows (7)?
There is no problems then using linux:
install.packages('RMySQL')
library(RMySQL)
...
But I found no such package for Windows on CRAN. There is only note about this fact.
I found package for version 2.10, but it is not usable in 2.12.1.
Also tried
install.packages("RMySQL", type="source")
but got an error :
* installing *source* package 'RMySQL' ...
ERROR: configuration failed for package 'RMySQL'
* removing 'C:/.../R/win-library/2.12/RMySQL'
Is there any way to connect to MySQL database from R in windows?
Found solution with help of ran2, who gave me link to common question. The basic process is described here, but there are several hints, So I will describe the whole solution (please change the R version and paths if needed):
Install latest RTools from here
install MySQL or header and library files of mysql
create or edit file C:\Program Files\R\R-2.12.1\etc\Renviron.site and add line like MYSQL_HOME=C:/mysql (path to your mysql files)
copy libmysql.lib from mysql/lib to mysql/lib/opt to meet dependencies.
copy libmysql.dll to C:\Program Files\R\R-2.12.1\bin or to windows/system32 directory.
run install.packages('RMySQL',type='source') and wait while compilation will end.
Thanks to all who tried to answer.
possible duplicate. However, my suggestions is to try WAMP which comes as a one click install. Admittedly you get more than you need (webserver) but the MySQL installation runs pretty well.
You need to install the MySQL headers and libraries, as explained in the installation instructions. Please do read the documentation before turning to SO.

MySQL and Matlab

I want to interact with a MySQL database from Matlab.
I found a mysql "library" for matlab here and the same on mathworks.
I followed the instructions to compile the library and the compilation seems to be successful. I get a mex32 file at the end. Only, the instructions on the first page refer to a Dll that I need to use (I guess that a Dll was supposed to be generated).
I am not familiar with the mex compiler or with compiling external modules for Matlab.
Am I missing something trivial? Where is the Dll supposed to be?
Thanks.
The reference to the dll is obsolete.
When you compile a mex function on Windows, you compile it as a dll (not an .exe). Thus, compiled mex functions used to have the extension .dll. Mex-functions with .dll extensions still work, but there is a warning that this might stop being the case in the future.
When 64-bit Windows arrived, TheMathWorks needed a way that people were to be able to compile the same mex-function for both Win32 and Win64, thus they changed the extension to .mexw32 and .mexw64, respectively. Apparently, they did not update the documentation completely.
I'd recommend using java to connect MATLAB and MySQL (or any other db if required).
The java database connector is simple to set up. I built a simple java class to connect to the database - see previous posting for a crude but working solution.
The MATLAB code works as indicated
% include java class
import Jam.ConnectToDatabase
% set up database connection info
userName='myName';
userPassword='myPassword';
databaseUrl='jdbc:mysql://glnd2818898.internal.net/2000';
% create java class instance and open connection to the database
ctd = ConnectToDatabase;
ctd.openConnection(userName, userPassword, databaseUrl)
Once the connection is open I can then use the java methods to submit SQL queries, create tables, insert data etc. I'd never used java before but I downloaded Netbeans and I was away.
OK, here is the solution to my problem.
The compilation does generate a mex32 file (32 is because I compiled it under a 32bit systme). You can check the output file of the compilation by running mexext. So apparently a mex32 file is a compiled version of the C file.
Once I placed the file in a directory that is in the Matlab's path it worked.
I guess the reference to the Dll in the link I provided is either obsolete or wrong.

Mysql Plug-in for Qt

I've installed recent Qt (4.5.3) sdk windows version. I'm want to use mysql in my app. Since Qt Mysql plugin in not available, so I compiled it from the included source. I copied compiled files D:\\Qt\2009.01\qt\plugins\sqldrivers.
Now when I run my application it still error "QMYSQL driver not loaded".
I suggest you take the whole Qt4 source code and compile it specifically for your own needs.
Something like this should do the job just fine:
Download the Qt source code from qt.nokia.com
Extract it somehwere and open a command prompt.
"cd" into the source directory and run "configure":
Just an example:
/Devel/qt/configure
-release
-fast
-opensource
-nomake "demos examples"
-silent
-qt-sql-mysql
You might have to additionally provide -I C:\path\to\mysql\includes and -L C:\path\to\mysql\libs.
After that, do "make install".
Hope that helps.
There may be several reasons leading to the driver not being loaded, I experienced several of them in my Qt experience.
Qt provides good documentation on this point, I suggest you have a look at the Troubleshooting subsection of Qt Assistant's SQL Database drivers section, it should help you diagnose your problem. It worked for me.
Hope that helps.
After compiling the plugin, you need to add the MySQL bin path to your PATH environment variable.