PDA

View Full Version : Connecting Qt with PostgreSql



JonathanVeg
18th April 2012, 00:54
Hello guys, I don't write in English very well. Sorry me possible errors.

I'm trying to connect PostgreSQL 9.1 with qt creator 4.7.3, but I don't able it.

I search in the Google and I found some libs and dlls about several drivers (MySQL, SQLite(I had already), PostgreSQL and Firebird). The QtCreator now recognizes two drivers, SQLite and Firebird, but he doesn't found the PostgreSQL driver.

For use Firebird driver I do nothing.

I already search various locations and I can't do it run.

Almost all tutorials I've found, have something like this:

http://qt-project.org/doc/qt-4.8/sql-driver.html#qpsql

But I can't to do this.

Neither the directories they say I have here, even after I adjust the instalation location.

Ps.: I already to copy the dll's for the right locations.

Thanks,

Jonathan.

p3c0
18th April 2012, 09:03
Hi jonathan,

1. Copy the files qsqlpsql.dll and libqsqlpsql.a (depending on what you have compiled i.e debug/release) to your "plugins\sqldrivers" path in "QTDIR"
2. Copy libeay32.dll,libintl-8.dll,libpq.dll and ssleay32.dll to your project directory

JonathanVeg
18th April 2012, 13:38
Hi jonathan,

1. Copy the files qsqlpsql.dll and libqsqlpsql.a (depending on what you have compiled i.e debug/release) to your "plugins\sqldrivers" path in "QTDIR"
2. Copy libeay32.dll,libintl-8.dll,libpq.dll and ssleay32.dll to your project directory

Hi p3c0.

I already did this and it's not work.

Qt only recognizes two drivers still. =/

I will end up reinstalling my Qt, for see if He work's right.

Thanks very much for your answer.

Added after 5 minutes:

There is one compilation static or simple mode to compile this in my case?

I'm searching it have three days. =x

JonathanVeg
18th April 2012, 21:25
I don't understand this.

Something I did, did the Qt recognize the driver, but he can't to load the driver.

QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QFIREBIRD QSQLITE QPSQL7 QPSQL

Someone have idea about this problem?

Ps.: I don't want know what I did for the Qt recognize the driver.

Thanks.

p3c0
19th April 2012, 11:18
can you tell the path where the file libeay32.dll,libintl-8.dll,libpq.dll and ssleay32.dll are present?
It must be present in release directory of your project

JonathanVeg
19th April 2012, 16:11
The dlls are already in the folder where is my executable.

I'm, now, using Firebird, because I'm a hurry for finish this program.

After the finish it, I need to learn how to connect PostgreSQL.

Thanks for answer me.

I still need to learn it, but I think it's problem with my QTCreator.

He is very instable, I don't know why.

If you have new ideas, you can post, because I will return here :D

In the worst, I will reinstalling my Qt and reconfigure it.

Off-topic: How is my English? I'm brazilian and I'm studing English since last year. Make the questions here, in English, helps me to test it. I'm avoinding the Google Translate.

No more, thanks for you help me.

JonathanVeg
22nd April 2012, 17:02
It worked!

I found a free project in Qt with PostgreSQL and he has the correct DLLs for I use with my Qt.

How more people should have the some question, I upload this archives for those who need.

The link are http://sourceforge.net/projects/pedyrum/files/SQLDrivers.rar/download

See you later.

JonathanVeg
24th April 2012, 23:26
Who know how I do for to connect the Postgresql in network?

It works in localhost, but don't work in local network.

I send IP, door, database name, username and password and never works.

I already configure the especifics files for Postgres and nothing.

Thanks.

Lesiok
25th April 2012, 07:55
Two possibilities :
- firewall on the PostgreSQL server computer
- PostgreSQL configuration - entries in the file pg_hba.conf

Take a look to PostgreSQL logs.

JonathanVeg
28th April 2012, 22:57
Thanks.

Now works.

I do it.

rajko
19th May 2012, 18:52
Hi, I'm not sure if I should open a new thread so I apologize if I had, but I have the same problem as Jonathan:

QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QFIREBIRD QSQLITE QPSQL7 QPSQL

I have win7 64 bit, postgresql 9.1, Qt 4.8.1, Qt creator 2.5
In PATH variable I added bin folders of postgres and qt, postgres is installed in c:\pgsql (no problem with white spaces), and lib folder of postgres.
I compiled Postgres sql driver plugin, I did it several times before, just this time it did not copy files automatically in qtdir/plugins/sqldrivers folder, I did it manually, i checked with QCoreApplication::libraryPaths(), it look in plugins folder where plugin resides, driver is availabile, I deleted plugin build keys from registry because I had previous installations of qt installed. Any suggestion is welcomed, thanks in advance.

edit:
I apologize for inconvenience but the problem after all is in my code, everything works now.Thank you nonetheless.