Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » SOLVED MySQL on remote DB: timeout or other issue
icon2.gif  SOLVED MySQL on remote DB: timeout or other issue [message #50025] Wed, 20 June 2018 11:08 Go to next message
forlano is currently offline  forlano
Messages: 1185
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

Re: MySQL on remote DB: timeout or other issue [message #50027 is a reply to message #50025] Thu, 21 June 2018 06:55 Go to previous message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
I found the solution.
The Connect command should be done one time.

Luigi
Previous Topic: MySQL & remote DB
Next Topic: Implementing PostgreSql returning statement
Goto Forum:
  


Current Time: Thu Apr 18 21:20:37 CEST 2024

Total time taken to generate the page: 0.01095 seconds