I've the following problem while trying to access a sql database through ip address
My code:



Qt Code:
  1. QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
  2. db.setHostName("66.xx.xxx.xxx");//ip masked for privacy
  3. db.setDatabaseName("john_stuff");
  4. db.setUserName("john_stuff");
  5. db.setPassword("12345");
  6.  
  7.  
  8. bool ok = db.open();
  9. error = db.lastError();
  10. if( ok )
  11. {
  12. ...
  13. }
To copy to clipboard, switch view to plain text mode 

I tried using different sql driver, QSQLITE, QPSQL and QPSQL7

Results using:
QSQLITE: ok = true, no errors throwed but no matter what ip address, username, password i enter it always say it's ok?
No firewall warnings.

QPSQL and QPSQL7: ok = false, lasterror always says
driver error: QPSQL: Unable to connect
databaseError: {"could not connect to server: Can't assign requested address (0x00002741/10049) Is the server running on host "66.xx.xxx.xxx" and accepting
TCP/IP connections on port 5432? " size=162}
ErrorType: ConnectionError
errorNumber: -1
My firewall throws a warning so it's really trying to connect to something online

I didn't understood the port warning so i tried using db.setPort( 3306 ) because in the past i used a program that used this port number to access the same database and it worked ok.
Results were: ok = false
databaseError {"expected authentication request from server, but received A" size=60}


I know that my available drivers are: QSQLITE QODBC3 QODBC QPSQL7 QPSQL

I'm total newbie at sql stuff, what i'm doing wrong here?