Seite 1 von 3
MySQL "Driver not loaded"
Verfasst: 26. Mai 2006 15:38
von stargazer
Hallo Leute. Also erst mal danke, an alle in diesem Forum, die schon mal etwas zum Thema MySQL Plugin gepostet haben. Denen habe ich es nämlich zu verdanken, dass ich es nach einigen Stunden Arbeit endlich geschafft habe das Plugin zu kompilieren. Tja, leider weiß ich nun nicht weiter.
Folgender Code:
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("xxx");
db.setDatabaseName("xxx");
db.setUserName("xxx");
db.setPassword("xxx");
bool ok = db.open();
if(ok == false)
{
QMessageBox::warning(this, "Fehler",
db.lastError().driverText()+"\r\n"+db.lastError().databaseText(),
"Ok", 0);
}else{
QMessageBox::warning(this, "Fehler",
"Alles OK\n"
"Ok", 0);
}
Ich habe das generierte Plugin in meinen Application Ordner unter "myApp/sqldrivers/" gelegt.
Beim komilieren gibt es keine Fehler. Nur beim starten der Anwendung kommt die Fehlermeldung "driver not loaded"
Hat jemand ne Ahnung, was ich noch machen kann? Vielleicht noch irgendwelche dlls irgendwohin schieben?
QT habe ich mit configure -plugins-sql-mysql configuriert und alles lief auch gut.
Danke schon mal!
Verfasst: 26. Mai 2006 16:09
von patrik08
Dann muss du eben auch deklarieren in welchen ordner nach plug-in suchen..
lese mal
http://www.qtcentre.org/forum/faq.php?f ... n_category
Applicationpathplug..... class QApplication....
Verfasst: 26. Mai 2006 17:25
von BartSimpson
normalerweise ssuchr er nur unter sqldrivers.
Desweitren muss die mysql DLL im Suchpfad liegen.
Verfasst: 26. Mai 2006 19:35
von stargazer
Hat leider alles nichts gebracht.
Alles was unter:
http://www.qtcentre.org/forum/faq.php?f ... n_category
zu finden ist, hat bei mir funktioniert.
configure -plugins-sql-mysql hat funktoniert.
Auch das erstellen der qsqlmysql.dll mit den mysql Sourcen hat funktioniert.
Jetzt habe ich in meinem sqldrivers Verzeichnis folgende Dateien:
qsqlmysql.dll
libmysql.dll
Eine mysql.dll gibt es nicht. Nur eine mysql.h. Doch wenn da was fehlen würde, würde der Compiler rumeckern. Ich steh vollkommen auf dem Schlauch.
Verfasst: 26. Mai 2006 19:45
von BartSimpson
die mysql.dll sollt im Suchpfad lieden.
Das Verzeichnis sqldrivers ist jedoch nicht der suchpfad. Versuche es mal die der Pfad Variablen von Windows den Pfad zu mysql.dll mit zu geben. dann sollte es gehen.
Haste das Plug In nach dieser Anleitung gabut?
=============================================================
Building the MySQL driver for Qt4/MinGW
==============================================================
Versions used: Qt4.0.0 / MinGW 3.4.2 / MySQL 4.1
1) Creating the MySQL client library.
- - - - - - - - - - - - - - - - - - -
Unfortunatly, the client libraries (libmysql.ddl and libmysql.lib)
shipped with MySQL are compiled with the M$ compiler and are causing
problems with try to link them with the MinGW compiler. Therefore,
we first need to create a MinGW compatible library out of libmysql.dll.
This can be done by taking the following steps:
# cd c:\mysql\lib\opt (c:\mysql is where our MySQL is installed)
# reimp -d libmysql.lib (reimp comes with MinGW utilities)
# dlltool -k --input-def libmysql.def --dllname libmysql.dll --output-lib
libmysql.a
Now we have the MinGW compatible library called libmysql.a
2) Building the QMYSQL plugin dll.
- - - - - - - - - - - - - - - - - -
Now we can build the Qt MySQL plugin based on the above MinGW compatible
library. This can be done by taking the following steps:
# cd c:\qt\src\plugins\sqldrivers\mysql (c:\qt is where qt is installed)
# qmake -o Makefile "INCLUDEPATH+=C:\MYSQL\INCLUDE"
"LIBS+=-LC:\MYSQL\LIB\OPT -lmysql" mysql.pro
# make (will build and install the plugin)
There is no need to change the mysql.pro file, because the -lmysql option
that is passed to the LIBS args, will disable the win32 section in the
mysql.pro
win32 {
!contains(LIBS, .*mysql.*) { # Returns false, so libmysql.lib will
not
LIBS *= libmysql.lib # be added.
}
}
3) libmysql.dll
- - - - - - - -
When you have build your qt application using the QMYSQL plugin, you have to
make
sure that libmysql.dll is in your path, or is resides next to your
executable.
Otherwise, the database open() call will fail with "Driver not loaded" in
the
SQLError return object.
Verfasst: 26. Mai 2006 19:56
von stargazer
Also auf meinem ganzen System gibt es keine mysql.dll javascript:emoticon(':(')
Sad
Wie schon gesagt, alles hat geklappt, die libmysql.dll hab ich erfolgreich erstellt und ich hab sie auch in mein sqldrivers Verzeichnis gepackt und auch direkt neben meine EXE Datei. Beides funzt nicht. Die Fehlermeldung lautet immer "Driver not loaded".
Noch andere Ideen?
Verfasst: 26. Mai 2006 20:00
von BartSimpson
Daste auch die passende Version vom Plug-in genommen. sprich die Debugversion oder Relase?
Verfasst: 26. Mai 2006 20:04
von stargazer
Ich habe sicherheitshalber beide Versionen:
libmysql.dll
libmysqld.dll
ins Verzeichnis gepackt.
Verfasst: 26. Mai 2006 20:11
von BartSimpson
und die Qt Plug-INS??
Verfasst: 26. Mai 2006 20:22
von stargazer
Oh Entschuldigung
Es sollte heißen:
qsqlmysql.dll
qsqlmysqld.dll
Sorry!
Verfasst: 26. Mai 2006 20:40
von patrik08
mach mal so...
cd :\qt\qt4\src\plugins\sqldrivers\sqlite
qmake
make
und wenn wenn alle 4 demo bei :\qt\qt4\examples\sql nicht laufen ..oder driver not found kommt .. dann rate ich dir qt4 neu zu bauen mit bereist alle sql + odbc + sqlite3 geladen....
configure.exe -help
Verfasst: 26. Mai 2006 20:54
von stargazer
Ich hab das mal gemacht und die Beispiele durchprobiert...laufen alle.
Verfasst: 26. Mai 2006 20:57
von stargazer
Kann diese "Driver not loaded" Meldung auch kommen, wenn ich das PlugIn mit den MySQL 5 Sourcen gebastelt habe aber versuche, auf eine 4er zu connecten?
Verfasst: 26. Mai 2006 21:04
von stargazer
Gibt es eigentlich noch andere Möglichkeiten, auf eine MySQL Datenbank zuzugreifen, auch wenn die Multi-Platform-Fähigkeiten von QT dadurch verloren gehen?
Verfasst: 26. Mai 2006 21:11
von patrik08
mach eine kleine test.exe mit dem driver mysql...
und wenn sogar
http://www.dependencywalker.com/ die dll nicht findet ..
muss du eben die class
http://doc.trolltech.com/4.0/qapplication.html dort gibts ein befehl set applicationplug-in path der genaue name kenne ich nicht..aber er ist da...
Ich update meinen mysql server im netz mit sqlite + QT4... & php5 ... ist mir schneller als auf diese verdammte verbindungen zu warten!
Der client qt4 mit sqlite downloadet die xml datenbank zum updaten .... in der zwischenzeit ist ein lock session das niemand anderen daten holen kann..
Wenn der client fertig ist sendet er die xml zum server ... und der fugt alles zu mysql..... wenn nicht updaten wird... geht der lock nach 2 stunden auf...
So kann man schnell arbeiten... ohne socket verbindungen auf dem server zu oefnen.... und risiko eingehen.... auch ohne lock geht es ... einfach der letzte der updatet REPLACE in to tabelle....