Page 1 of 1

Load Balancing in MySQL - connection string

Posted: Wed 23 Oct 2013 15:34
by rthon
This has been a feature I have long waited for. Thank you!

Is there an example of a connection string using this feature?
I've tried everything and I'm still having errors when I call to OPEN the database.

Current code: (This is the code that works today pointing to a single MySQL server)
MySqlConnection DbConnection = new MySqlConnection();
DbConnection.Host = "server1";
DbConnection.Port = 3306;
DbConnection.UserId = "MNT";
DbConnection.Password = "MNT";
DbConnection.Compress = true;
DbConnection.Database = "MNT";
try
{
DbConnection.Open();
}
catch (OdbcException e)
{

How would I re-write it to point to server1 port 3306 (as PRIMARY) and server2 port 3306 (as SECONDARY) using the new Load Balancing support in version 8 professional?

Thank you so much for the help.

Re: Load Balancing in MySQL - connection string

Posted: Thu 24 Oct 2013 14:25
by Pinturiccio
For using load balancing you have to specify all servers with their ports in Host property. The following code will use the loadbal bancing feature:

Code: Select all

MySqlConnection DbConnection = new MySqlConnection();
DbConnection.Host = "server1:3306,server2:3306";
DbConnection.UserId = "MNT";
DbConnection.Password = "MNT";
DbConnection.Compress = true;
DbConnection.Database = "MNT";
try
{
DbConnection.Open();
}
...
For more information, please refer to http://forums.devart.com/viewtopic.php?t=28132
http://blogs.devart.com/dotconnect/orac ... ducts.html

Re: Load Balancing in MySQL - connection string

Posted: Thu 24 Oct 2013 15:47
by rthon
Thank you! I've give that a try. In the dotConnect for MySQL 8.0 release statement, it shows a semi-colon between the addresses & ports combinations. I didn't know that it should have3 been a comma.

Thanks,

Re: Load Balancing in MySQL - connection string

Posted: Thu 24 Oct 2013 16:07
by rthon
to properly get this working...
This was the change I had to make:

... = "(server1:3306,server2:3306)";

Re: Load Balancing in MySQL - connection string

Posted: Fri 25 Oct 2013 14:48
by Pinturiccio
You are right. Servers and ports must be enclosed in parentheses.