query failed

Post

Posted
Rating:
#1 (In Topic #2037)
Avatar
Regular
LEISSLER is in the usergroup ‘Regular’
Hello everyone

If my user stays on the screen for a while without confirming anything, during data saving,

I get this error:
"Query failed: lost connection to MySQL server during query"

How do I reopen the connection?
I tried:
"If conn.Opened = False Then conn.Open"
but without success.

Any ideas?

Regards, Eric
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Expert
Quincunxian is in the usergroup ‘Expert’
Quincunxian is in the usergroup ‘Blogger’
Is your server local (on your local network)  or remote in a distant location ?

I'm in Perth Australia and I connect to a MySQL server in Asia ( somewhere?) and get that disconnect from time to time.
It's a timeout set at the database level which is normally (MySql Official) 30 seconds but I think the Gambas default is 20 seconds.

You can set this higher but it will depend on how it is set up.

I find that fully closing the connection and then doing a reconnect seems to fix the connection issue.

Code

Public Sub OpenRemoteConnection()
  
  $MySQL = New Connection
  $MySQL.Close
  
  $MySQL.Timeout = MyTimeOut '<----------<<< Try setting a time out to 100(?) seconds and see if that helps
  $MySQL.Type = MyType
  $MySQL.Host = MyHost
  $MySQL.Login = MyLogon
  $MySQL.Password = MyPassword
  $MySQL.Port = MyPort
  $MySQL.Name = MyDatabaseName
  Try
  $MySQL.Open
  
Catch
  Message(Error.Text)
  
End

Cheers - Quin.
I code therefore I am
Online now: No Back to the top
1 guest and 0 members have just viewed this.