Home JBoss howto Persistence - Database How do you connect a Datasource to a Cluster ?
30 | 07 | 2010
JBoss 5 AS Book
"JBoss AS 5 development" reviews
Please share your feedback/review with other readers!
Banner
Dashboard
Advertise with Us
Banner
RSS Feed
Java EE 1.6 resources
Login
Sign here for the NewsLetter.



JBoss admin resources
Banner
Java EE 1.6 resources
JBoss howto

How to avoid the 50 seconds start up limit in Eclipse ?

JBoss recipe of the day ...
Read More

How can you solve deployment errors caused by large war/jar/ear files ?

jboss recipe of the day ...
Read More

How do you configure your .war to be deployed after your EJB ?

jboss recipe of the day ...
Read More
How do you connect a Datasource to a Cluster ?
Written by F.Marchioni   

JBoss recipe of the day
 

We'll examine two popular Database: Oracle and MySQL

Oracle cluster (RAC)

Oracle RAC allows multiple computers to run the Oracle RDBMS software simultaneously while accessing a single database  thus providing a clustered database.
In order to benefit from Oracle RAC features like fault tolerance and load balancing all you have to do is configuring the connection url with the list of Oracle hosts which belongs to the cluster.

In this example we are configuring our datasource to connect to a RAC made up of host1 and host2:

 

<connection-url>

    jdbc:oracle:thin:@(description=(address_list=(load_balance=on)(failover=on)       (address=(protocol=tcp)(host=host1)(port=1521))(address=(protocol=tcp)(host=host2)(port=1521)))(connect_data=(service_name=xxxxsid)(failover_mode=(type=select)(method=basic))))

</connection-url>

My SQL cluster

MySQL Cluster is a real-time open source transactional database designed for fast, always-on access to data under high throughput conditions.

In order to achieve load-balancing and failover across MySQL cluster you need to modify your jdbc Connection string adding the "loadbalance" keyword

to do load-balancing across the SQL nodes in MySQL Cluster, you would use a different JDBC connection string with the "loadbalance" keyword added

<connection-url>

jdbc:mysql:loadbalance://host-1,host-2,...host-n/database?loadBalanceBlacklistTimeout=5000

</connection-url>

Notice the "loadBalanceBlacklistTimeout" adds the needed feature that failed connections in a connection pool are put aside for the specified time, and only working connections are utilized. This parameter is essential for proper failover.


JBoss.org Search
Custom Search
Comments
Search
Only registered users can write comments!

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."