{
MappedStoreManager storeMgr = (MappedStoreManager)omfContext.getStoreManager();
if (storeMgr != null && storeMgr.getDatastoreAdapter() != null)
{
// Create Connection following DatastoreAdapter capabilities
RDBMSAdapter rdba = (RDBMSAdapter)storeMgr.getDatastoreAdapter();
int reqdIsolationLevel = isolation;
if (rdba.getRequiredTransactionIsolationLevel() >= 0)
{
// Override with the adapters required isolation level
reqdIsolationLevel = rdba.getRequiredTransactionIsolationLevel();
}
DataSource[] ds = (DataSource[])dataSource;
cnx = new ConnectionProviderPriorityList().getConnection(ds);
boolean succeeded = false;
try
{
if (reqdIsolationLevel == UserTransaction.TRANSACTION_NONE)
{
if (!cnx.getAutoCommit())
{
cnx.setAutoCommit(true);
}
}
else
{
if (cnx.getAutoCommit())
{
cnx.setAutoCommit(false);
}
if (rdba.supportsTransactionIsolationLevel(reqdIsolationLevel))
{
int currentIsolationLevel = cnx.getTransactionIsolation();
if (currentIsolationLevel != reqdIsolationLevel)
{
cnx.setTransactionIsolation(reqdIsolationLevel);