PDA

View Full Version : Accessing xampp mysql database



synack
9th March 2009, 10:14
Hi folks,

here is what I want to do:

I'running an apache mysql server with xampp on a windows vista 32bit machine (would like to do this with linux, but have to do it with vista...) and want to access a database through the QSqlTableModel in my xampp/mysql directory.
The dev packs(lib and header) for mysql is installed.

Qt Version is 4.4.3 and i tried to install the mysql plugin with the following command in the Qt command prompt: "c:\Qt\4.4.3\src\plugins\sqldrivers\mysql>qmake "INCLUDEPATH+=C:\xampp\MySQL\incl
ude" "LIBS+=C:\xampp\MySQL\lib\opt\libmysql.lib" mysql.pro"
This command works, but when i do a "make" afterwards, i get lots of errors with 'undefined references to 'mysql_query@8'' and exit status 1.

Helpful:
http://doc.trolltech.com/4.4/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows and
http://wiki.qtcentre.org/index.php?title=Building_the_QMYSQL_plugin_on_Wind ows_using_MinGW

Installing latest mingw and using reimp should work.

What did i do wrong?
Does the mysql server has to be running when installing? - i guess no -
Is the process for installing the mysql plugin similiar for Qt4.5?
Do I need to have the mysql running as a service in my xampp control center, when I want to access the database?
Has anybody experience with this issue?

Any help would be a peach

Best Regards
--synack

synack
10th March 2009, 10:04
Hi,

in context to this article

http://wiki.qtcentre.org/index.php?title=Building_the_QMYSQL_plugin_on_Wind ows_using_MinGW

I need a little bit help please.

The scenario is the mentioned above. I did steps 1-4 how described in the wiki article and no errors.
At step 5 when doing 'make', I get these errors:

<pre>
C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/winbase.h:1676: error:
declaration of C function `LONG InterlockedIncrement(volatile LONG*)' conflicts
with
../../../../include/QtCore/../../src/corelib/arch/qatomic_windows.h:388: error:
previous declaration `long int InterlockedIncrement(long int*)' here
mingw32-make[1]: *** [tmp/obj/release_shared/main.o] Error 1
mingw32-make[1]: Leaving directory `c:/Qt/4.4.3/src/plugins/sqldrivers/mysql'
mingw32-make: *** [release-all] Error 2
</pre>

I really have no glue that i'm doing wrong.
MinGW works, the lib and header for mysql is installed, reimp works, liblibmysql.a has been created, so if you have any suggestions post them.

Regards
--synlag

synack
10th March 2009, 10:41
Perhaps this an issue for the bug tracker.

Here's that really simple code, i want to run:



#include <QtGui>
#include <QtSql>
#include <QtDebug>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");

db.setHostName("localhost");
db.setDatabaseName("c5testdb");
db.setUserName("root");
db.setPassword("");

if(!db.open()) {
QSqlError err = db.lastError();
QMessageBox::information(0, QObject::tr("Fehler!"), err.text());
return 1;
}

QTableView tableView;
QSqlTableModel model;

model.setTable("users");
model.select();
model.setEditStrategy(QSqlTableModel::OnFieldChang e);
tableView.setModel(&model);
tableView.setWindowTitle("SQL-Demonstration");
tableView.show();
return a.exec();
}


;)

spirit
10th March 2009, 10:44
create QSqlTableModel model; on a heap.

synack
10th March 2009, 10:55
create QSqlTableModel model; on a heap.

:confused:

Did you read the two posts above? I think no you didn't.
For this example it makes no difference if the model is on heap or stack.

synack
16th March 2009, 11:01
Does anyone has experience setting up a mysql connection with Qt4.5 ?

spirit
16th March 2009, 11:03
yup, works fine for me.

synack
16th March 2009, 11:18
Ok, it would be nice if you could explain what is the difference between installing mysql on a windows machine to the previous Qt version, if there is any.
I did it like described in this article
http://wiki.qtcentre.org/index.php?title=Building_the_QMYSQL_plugin_on_Wind ows_using_MinGW
but it does not work for Qt4.5

Thx so far

synack
19th March 2009, 09:08
wimblows, so i'm back on my lamp now...
works fine so far, and when i've time i'll maybe look into it, making the app work for win