Load Balancing in MySQL - connection string

Load Balancing in MySQL - connection string

Postby rthon » Wed 23 Oct 2013 15:34

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.
rthon
 
Posts: 3
Joined: Wed 23 Oct 2013 14:56

Re: Load Balancing in MySQL - connection string

Postby Pinturiccio » Thu 24 Oct 2013 14:25

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/oracle-12c-support-and-more-new-features-in-new-versions-of-devart-products.html
Pinturiccio
Devart Team
 
Posts: 2026
Joined: Wed 02 Nov 2011 09:44

Re: Load Balancing in MySQL - connection string

Postby rthon » Thu 24 Oct 2013 15:47

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,
rthon
 
Posts: 3
Joined: Wed 23 Oct 2013 14:56

Re: Load Balancing in MySQL - connection string

Postby rthon » Thu 24 Oct 2013 16:07

to properly get this working...
This was the change I had to make:

... = "(server1:3306,server2:3306)";
rthon
 
Posts: 3
Joined: Wed 23 Oct 2013 14:56

Re: Load Balancing in MySQL - connection string

Postby Pinturiccio » Fri 25 Oct 2013 14:48

You are right. Servers and ports must be enclosed in parentheses.
Pinturiccio
Devart Team
 
Posts: 2026
Joined: Wed 02 Nov 2011 09:44


Return to dotConnect for MySQL