Home » U++ Library support » U++ SQL » SOLVED MySQL on remote DB: timeout or other issue
SOLVED MySQL on remote DB: timeout or other issue [message #50025] |
Wed, 20 June 2018 11:08  |
 |
forlano
Messages: 1207 Registered: March 2006 Location: Italy
|
Senior Contributor |
|
|
Hello,
I am able to connect to a MySQL remote server with a code like this one
if(session.Connect("user", "pass", "db", "111.111.111.111")) {
try {
//...
}
catch(SqlExc &ex) {
Cerr() << "ERROR: " << ex << "\n";
SetExitCode(1);
}
}
else {
Cerr() <<"ERROR: Unable to connect to database\n";
SetExitCode(1);
}
where session is a global variable:
MySqlSession session;
However after say 60 seconds and 4 or 5 queries the connection cannot be longer done and I get the message
"ERROR: Unable to connect to database\n";
Then I close and restart the program and the connection continue to work for other 60 seconds.
It seems there is a sort of timeout in the connection made by my program.
I have some questions:
1. is there a way to set a timeout limit?
2. the instruction
session.Connect("user", "pass", "db", "111.111.111.111")
should be executed only one time for all during the timelife of the program
or
each time a query is performed?
At moment I am using the last approach but I suspect it is wrong.
3. when I should use session.Close()?
Thanks,
Luigi
[Updated on: Thu, 21 June 2018 06:56] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Tue Apr 29 05:51:12 CEST 2025
Total time taken to generate the page: 0.00727 seconds
|