org.datanucleus.store.rdbms
Class ConnectionProviderPriorityList
java.lang.Object
org.datanucleus.store.rdbms.ConnectionProviderPriorityList
- All Implemented Interfaces:
- ConnectionProvider
public class ConnectionProviderPriorityList
- extends Object
- implements ConnectionProvider
Utility class for Failover.
|
Method Summary |
Connection |
getConnection(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 |
ConnectionProviderPriorityList
public ConnectionProviderPriorityList()
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 Connection getConnection(DataSource[] ds)
throws 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:
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 © 2012. All Rights Reserved.