3 messages in com.mysql.lists.javaRe: issues with mysql cluster| From | Sent On | Attachments |
|---|---|---|
| Victor Medina | 08 Oct 2004 08:37 | |
| Mark Matthews | 08 Oct 2004 09:45 | |
| Victor Medina | 08 Oct 2004 10:35 |
| Subject: | Re: issues with mysql cluster![]() |
|---|---|
| From: | Mark Matthews (ma...@mysql.com) |
| Date: | 10/08/2004 09:45:50 AM |
| List: | com.mysql.lists.java |
On Fri, 2004-10-08 at 11:38 -0400, Victor Medina wrote:
Hi all!
When dealing with MySQL clusters using ndb... I have configured a 4 nodes under linux. I would like to access the 4nodes cluster using jdbc... how do i specify that the application should connect to any of the db servers in the cluster using connector/j?
Vic.
Vic.
It's pretty simple, if by when you mean you have 4 _mysql_ servers 'fronting' the cluster...Connector/J doesn't 'talk' directly to the NDB cluster, it talks to the mysql server nodes that store data _in_ the cluster.
If this is the case, you need to use 'autoReconnect=true', 'failOverReadOnly=false' and 'roundRobinLoadBalance=true' in your JDBC URL, and also specify a list of hosts...This might look something like this:
jdbc:mysql://host1,host2,host3/test? user=foo&password=foo&autoReconnect=true&failOverReadOnly=false&roundRobinLoadBalance=true
This will configure Connector/J to connect to hosts in a round-robin fashion, both when creating a new connection, and when failing over an existing connection. You should be aware that failover _only_ happens outside a transaction, so the easy way to ensure this happens is that your connection pool is calling 'setAutoCommit(true)' before handing out the connection to you (which is generally required by the JDBC spec).
Regards,
-Mark




