Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. PostgreSQL driver for Windows w/MinGW

PostgreSQL driver for Windows w/MinGW

Scheduled Pinned Locked Moved Installation and Deployment
3 Posts 2 Posters 4.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    someguy
    wrote on 11 Jul 2011, 15:17 last edited by
    #1

    Hi everyone,

    I had a hopefully brief question. Using the first portion of this "guide":http://www.qtcentre.org/wiki/index.php?title=Building_the_QPSQL_plugin_on_Windows_using_MinGW I was able to build my PostgreSQL driver such that I no longer encountered the error "QSqlDatabase: QPSQL driver not loaded", but I'm still not connecting to my PostgreSQL database. For reference, I'm using Qt 4.7.3/MinGW/Win7 Home Premium 64-bit/PostgreSQL 8.4.

    I'm just simply doing this for testing purposes:

    @
    QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
    qDebug() << (db.isValid() ? "VALID" : "ERROR");

    db.setHostName("localhost");
    db.setDatabaseName("test");
    db.setUserName("postgre");
    db.setPassword("password");
    db.setPort(5432);
    
    bool ok = db.open();
    
    if (ok) ui->lineEdit->setText("worked!");
    else ui->lineEdit->setText("didn't work");
    

    @

    I'm getting the 'VALID' response in my debug window, so things can't be going too terribly, but I continually recieve the 'didn't work' into my lineEdit, meaning it couldn't open the database. I'm sure I have the correct port and database name, but I'm not entirely clear on if my host is right (I think so, the PostgreSQL is locally installed and running on this computer), or if I can use the main username/password in that fashion.

    I've examined the qsqlpsql4d.dll driver with Dependency Walker and fixed any .dlls it couldn't find, but I'm still left with some irritating 'multiple CPU types found' as a result of Windows APIs on my 64-bit Win7. I'm not sure if this is important or not.

    I can connect to my PostgreSQL database through pgAdminIII just fine, so it isn't the database.

    Am I just being stupid and not putting the right user/pass in?

    Additionally, a second question: If I intend to port this over to a Mac, do I need to build the PostgreSQL driver for Mac, or will my project work fine once ported from Windows?

    Thanks a bunch.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alexisdm
      wrote on 11 Jul 2011, 15:56 last edited by
      #2

      You can get more explicit errors with QSqlDatabase::lastError:
      @else ui->lineEdit->setText("didn't work" + db.lastError().text());@

      bq. Additionally, a second question: If I intend to port this over to a Mac, do I need to build the PostgreSQL driver for Mac, or will my project work fine once ported from Windows?

      Yes, you will have to recompile the driver for each OS.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        someguy
        wrote on 11 Jul 2011, 16:10 last edited by
        #3

        Wow, that was a very helpful line to add and allowed me to figure out the issue. Basically, I forgot to add the 's' at the end of the username 'postgres'. I feel dumb, but everything is working now.

        I appreciate the answer to my second question as well,

        Thank you very much!

        1 Reply Last reply
        0

        1/3

        11 Jul 2011, 15:17

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved