Mrdata
24th May 2007, 11:15
I've the following problem while trying to access a sql database through ip address
My code:
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setHostName("66.xx.xxx.xxx");//ip masked for privacy
db.setDatabaseName("john_stuff");
db.setUserName("john_stuff");
db.setPassword("12345");
bool ok = db.open();
error = db.lastError();
if( ok )
{
...
}
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?
My code:
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setHostName("66.xx.xxx.xxx");//ip masked for privacy
db.setDatabaseName("john_stuff");
db.setUserName("john_stuff");
db.setPassword("12345");
bool ok = db.open();
error = db.lastError();
if( ok )
{
...
}
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?