i need to connect to mysql server over the web
my code is like this and working good on localhost
Code: Select all
try
try
UniConnectionRead := TUniConnection.Create(nil);
UniConnectionRead.ProviderName:='Mysql';
UniConnectionRead.Server := globalDBIP;
UniConnectionRead.Username := globalDBUn;
UniConnectionRead.Password := globalDBPass;
UniConnectionRead.Database := globalDBName;
UniConnectionRead.AutoCommit := true;
UniConnectionRead.SpecificOptions.Values['MySQL.UseUnicode'] := 'True';
UniConnectionRead.Connected := true;
UniQueryRead := tuniquery.Create(nil);
UniQueryRead.Connection := UniConnectionRead;
//code for read write to database
Except
Form1.ListBox1.Items.Add('Error:cant get atunomy page list from database!');
end;
finally
UniQueryRead.Free;
UniConnectionRead.Free;
end;
i have two question for a better experience :
1)how can do a reconnect or handle error to avoid crashes
2)i have some codes in my application thos connecting to database server separately,can i use one single connection for all 'tuniquery' ? i mean i have one connaction and handle its reconnect to server and 20-30 tuniquery use this connection to connect to server!? (now each tuniquery have its own TUniConnection )
Thank you