use of javax.resource.spi.ManagedConnection in project jaybird by FirebirdSQL.
the class TestFBXAResource method testStartXATrans.
@Test
public void testStartXATrans() throws Exception {
FBManagedConnectionFactory mcf = initMcf();
ManagedConnection mc = mcf.createManagedConnection(null, null);
FBManagedConnection fbmc = (FBManagedConnection) mc;
XAResource xa = mc.getXAResource();
Xid xid = new XidImpl();
xa.start(xid, XAResource.TMNOFLAGS);
assertNotNull("no db handle after start xid", fbmc.getGDSHelper().getCurrentDatabase());
xa.end(xid, XAResource.TMSUCCESS);
xa.commit(xid, true);
mc.destroy();
}
use of javax.resource.spi.ManagedConnection in project jaybird by FirebirdSQL.
the class TestFBXAResource method test2PCXATrans.
@Test
public void test2PCXATrans() throws Exception {
FBManagedConnectionFactory mcf = initMcf();
ManagedConnection mc = mcf.createManagedConnection(null, null);
FBManagedConnection fbmc = (FBManagedConnection) mc;
XAResource xa = mc.getXAResource();
Xid xid = new XidImpl();
xa.start(xid, XAResource.TMNOFLAGS);
assertNotNull("no db handle after start xid", fbmc.getGDSHelper().getCurrentDatabase());
xa.end(xid, XAResource.TMSUCCESS);
xa.prepare(xid);
xa.commit(xid, false);
mc.destroy();
}
use of javax.resource.spi.ManagedConnection in project camunda-bpm-platform by camunda.
the class JcaExecutorServiceManagedConnectionFactory method matchManagedConnections.
@SuppressWarnings("rawtypes")
public ManagedConnection matchManagedConnections(Set connectionSet, Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
ManagedConnection result = null;
Iterator it = connectionSet.iterator();
while (result == null && it.hasNext()) {
ManagedConnection mc = (ManagedConnection) it.next();
if (mc instanceof JcaExecutorServiceManagedConnection) {
result = mc;
}
}
return result;
}
use of javax.resource.spi.ManagedConnection in project Payara by payara.
the class JdbcAdminServiceImpl method getValidationTableNames.
/**
* Get Validation table names list for the database that the jdbc
* connection pool refers to. This is used for connection validation.
* @param poolInfo
* @return all validation table names.
* @throws javax.resource.ResourceException
* @throws javax.naming.NamingException
*/
public Set<String> getValidationTableNames(PoolInfo poolInfo) throws ResourceException {
ManagedConnectionFactory mcf = null;
ManagedConnection mc = null;
java.sql.Connection con = null;
try {
mc = (ManagedConnection) ccPoolAdmService.getUnpooledConnection(poolInfo, null, false);
mcf = ccPoolAdmService.obtainManagedConnectionFactory(poolInfo);
if (mc != null) {
con = (java.sql.Connection) mc.getConnection(null, null);
}
return getValidationTableNames(con, getDefaultDatabaseName(poolInfo, mcf));
} catch (Exception re) {
_logger.log(Level.WARNING, "pool.get_validation_table_names_failure", re.getMessage());
throw new ResourceException(re);
} finally {
try {
if (mc != null) {
mc.destroy();
}
} catch (Exception ex) {
if (_logger.isLoggable(Level.FINEST)) {
_logger.log(Level.FINEST, "pool.get_validation_table_names_mc_destroy", poolInfo);
}
}
}
}
use of javax.resource.spi.ManagedConnection in project Payara by payara.
the class JdbcRecoveryResourceHandler method closeConnections.
/**
* {@inheritDoc}
*/
@Override
public void closeConnections(List connList) {
for (Object obj : connList) {
try {
ManagedConnection con = (ManagedConnection) obj;
con.destroy();
} catch (Exception ex) {
_logger.log(Level.WARNING, "recovery.jdbc-resource.destroy-error", ex);
}
}
}
Aggregations