org.datanucleus.store.rdbms
Class ConnectionProviderPriorityList

java.lang.Object
  extended by org.datanucleus.store.rdbms.ConnectionProviderPriorityList
All Implemented Interfaces:
ConnectionProvider

public class ConnectionProviderPriorityList
extends java.lang.Object
implements ConnectionProvider

Utility class for Failover

Version:
$Revision: 1.2 $

Constructor Summary
ConnectionProviderPriorityList()
           
 
Method Summary
 java.sql.Connection getConnection(javax.sql.DataSource[] ds)
          Obtain a connection from the datasources, starting on the first datasource, and if unable to obtain a connection skips to the next one on the list, and try again until the list is exhausted.
 void setFailOnError(boolean flag)
          Flag if an error causes the operation to thrown an exception, or false to skip to next DataSource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionProviderPriorityList

public ConnectionProviderPriorityList()
Method Detail

setFailOnError

public void setFailOnError(boolean flag)
Description copied from interface: ConnectionProvider
Flag if an error causes the operation to thrown an exception, or false to skip to next DataSource. if an error occurs on the last DataSource on the list an Exception will be thrown no matter if failOnError is true or false. This is a hint. Implementations may ignore the user setting and force it's own behaviour

Specified by:
setFailOnError in interface ConnectionProvider
Parameters:
flag - true if to fail on error

getConnection

public java.sql.Connection getConnection(javax.sql.DataSource[] ds)
                                  throws java.sql.SQLException
Obtain a connection from the datasources, starting on the first datasource, and if unable to obtain a connection skips to the next one on the list, and try again until the list is exhausted.

Specified by:
getConnection in interface ConnectionProvider
Parameters:
ds - the array of datasources. An ordered list of datasources
Returns:
the Connection, null if ds is null, or null if the DataSources has returned a null as connection
Throws:
java.sql.SQLException - in case of error and failOnError is true or the error occurs while obtaining a connection with the last DataSource on the list


Copyright © 2009. All Rights Reserved.