org.datanucleus.store.rdbms
Interface ConnectionProvider

All Known Implementing Classes:
ConnectionProviderPriorityList

public interface ConnectionProvider

Connects to a DataSource to obtain a Connection. The ConnectionProvider is not a caching and neither connection pooling mechanism. The ConnectionProvider exists to perform failover algorithm on multiple DataSources when necessary. One instance per StoreManager (RDBMSManager) is created. Users can provide their own implementation via the extension org.datanucleus.store_connectionprovider


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.
 

Method Detail

setFailOnError

void setFailOnError(boolean flag)
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

Parameters:
flag - true if to fail on error

getConnection

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.

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.