Interface DatasourceManager
public interface DatasourceManager
-
Method Summary
Modifier and TypeMethodDescriptionbeginTransaction
(String datasource, int isolationLevel, long timeout) Begins a transaction against the named datasource.void
beginTransaction
(String id, String datasource, int isolationLevel, long timeout) Named queries want to specify their own transaction ID.void
closeTransaction
(String txId) Closes the given transaction.void
commitTransaction
(String txId) Commits any pending statements for the given transaction.getConnection
(long dataSource) Retrieves a JDBC new connection for the datasource with the given id.getConnection
(String dataSource) Retrieves a JDBC new connection for the given named datasource.getDatasource
(long id) getDatasource
(String name) Looks up a datasource by name.Returns a list of all known datasources currently installed.Returns the connection for a given transaction id.void
rollbackTransaction
(String txId) Rolls back any statements executed on this transaction since the last commit or since the beginning of the transactionvoid
touchTransaction
(String txId) Updates the last-used time for the transaction, if it still exists.
-
Method Details
-
getConnection
Retrieves a JDBC new connection for the given named datasource. If the datasource named is currently faulted, the connection may come from its failover datasource, if there is one.- Throws:
IllegalArgumentException
- if the provided datasource does not exist.SQLException
-
getConnection
Retrieves a JDBC new connection for the datasource with the given id. If the datasource is currently faulted, the connection may come from its failover datasource, if there is one.- Throws:
SQLException
-
beginTransaction
Begins a transaction against the named datasource.- Parameters:
datasource
- The name of the datasource to useisolationLevel
- a constant from java.sql.Connection indicating the new transaction's isolation level.timeout
- Time to wait between uses of the transaction's connection before it will be automatically rolled back and closed.- Returns:
- A new transaction ID, which will be used for all further interaction with this transaction.
- Throws:
SQLException
-
beginTransaction
void beginTransaction(String id, String datasource, int isolationLevel, long timeout) throws SQLException Named queries want to specify their own transaction ID. No return value needed, because we specified ID.- Parameters:
id
- The transaction ID. Not empty.datasource
- The name of the datasource to use.isolationLevel
- a constant from java.sql.Connection indicating the new transaction's isolation level.timeout
- Time to wait between uses of the transaction's connection before it will be automatically rolled back and closed.- Throws:
SQLException
-
commitTransaction
Commits any pending statements for the given transaction.- Throws:
SQLException
-
rollbackTransaction
Rolls back any statements executed on this transaction since the last commit or since the beginning of the transaction- Throws:
SQLException
-
closeTransaction
Closes the given transaction. The transaction ID is no longer valid after this method completes.- Throws:
SQLException
-
touchTransaction
Updates the last-used time for the transaction, if it still exists. -
getTransactionConnection
Returns the connection for a given transaction id.- Throws:
SQLException
-
getDatasource
Looks up a datasource by name. Will return null if the datasource doesn't exist -
getDatasource
-
getDatasources
List<Datasource> getDatasources()Returns a list of all known datasources currently installed. This list is not backed by the manager - changes to it will not have any effect. -
getMetaProvider
DatasourceMetaProvider getMetaProvider()
-