use of javax.sql.PooledConnection in project geode by apache.
the class GemFireTransactionDataSource method getSQLConnection.
/**
* gets the connection from the pool
*
* @param poolC
* @return ???
*/
protected Connection getSQLConnection(PooledConnection poolC) throws SQLException {
Connection conn = poolC.getConnection();
boolean val = validateConnection(conn);
if (val)
return conn;
else {
provider.returnAndExpireConnection(poolC);
throw new SQLException(LocalizedStrings.GemFireTransactionDataSource_GEMFIRECONNPOOLEDDATASOURCEGETCONNFROMCONNPOOLJAVASQLCONNECTION_OBTAINED_IS_INVALID.toLocalizedString());
}
}
use of javax.sql.PooledConnection in project geode by apache.
the class GemFireTransactionDataSource method connectionErrorOccurred.
/**
* Implementation of call back function from ConnectionEventListener interface. This callback will
* be invoked on connection error event.
*
* @param event Connection event object
*/
public void connectionErrorOccurred(ConnectionEvent event) {
if (isActive) {
try {
PooledConnection conn = (PooledConnection) event.getSource();
provider.returnAndExpireConnection(conn);
} catch (Exception ex) {
String exception = "GemFireTransactionDataSource::connectionErrorOccurred: Exception occurred due to " + ex;
if (logger.isDebugEnabled()) {
logger.debug(exception, ex);
}
}
}
}
use of javax.sql.PooledConnection in project geode by apache.
the class TranxPoolCacheImpl method getNewPoolConnection.
/**
* Creates a new connection for the pool. This connection can participate in the transactions.
*
* @return the connection from the database as PooledConnection object.
*/
@Override
public Object getNewPoolConnection() throws PoolException {
if (m_xads != null) {
PooledConnection poolConn = null;
try {
poolConn = m_xads.getXAConnection(configProps.getUser(), configProps.getPassword());
} catch (SQLException sqx) {
throw new PoolException(LocalizedStrings.TranxPoolCacheImpl_TRANXPOOLCACHEIMPLGETNEWCONNECTION_EXCEPTION_IN_CREATING_NEW_TRANSACTION_POOLEDCONNECTION.toLocalizedString(), sqx);
}
poolConn.addConnectionEventListener((javax.sql.ConnectionEventListener) connEventListner);
return poolConn;
} else {
if (logger.isDebugEnabled()) {
logger.debug("TranxPoolCacheImpl::getNewConnection: ConnectionPoolCache not intialized with XADatasource");
}
throw new PoolException(LocalizedStrings.TranxPoolCacheImpl_TRANXPOOLCACHEIMPLGETNEWCONNECTION_CONNECTIONPOOLCACHE_NOT_INTIALIZED_WITH_XADATASOURCE.toLocalizedString());
}
}
use of javax.sql.PooledConnection in project cdap by caskdata.
the class DBConnectionPoolManager method dispose.
/**
* Closes all unused pooled connections.
*/
public synchronized void dispose() throws SQLException {
if (isDisposed) {
return;
}
isDisposed = true;
SQLException e = null;
while (!recycledConnections.isEmpty()) {
PooledConnection pconn = recycledConnections.remove();
try {
pconn.close();
} catch (SQLException e2) {
if (e == null) {
e = e2;
}
}
}
if (e != null) {
throw e;
}
}
use of javax.sql.PooledConnection in project spanner-jdbc by olavloite.
the class CloudSpannerConnectionPoolDataSourceTest method createDataSourceTest.
@Test
public void createDataSourceTest() throws SQLException {
CloudSpannerConnectionPoolDataSource subject = new CloudSpannerConnectionPoolDataSource();
subject.setProjectId("helpful-adroit-123456");
subject.setInstanceId("test-instance");
subject.setDatabase("test");
subject.setPvtKeyPath("C:\\Users\\MyUserName\\Documents\\CloudSpannerKeys\\cloudspanner-key.json");
subject.setPvtKeyPath(null);
subject.setOauthAccessToken("TEST");
subject.setSimulateProductName("PostgreSQL");
subject.setAllowExtendedMode(true);
subject.setLoginTimeout(10);
subject.setDefaultAutoCommit(false);
subject.setLogWriter(new PrintWriter(System.out));
Assert.assertEquals("ConnectionPoolDataSource from " + nl.topicus.jdbc.CloudSpannerDriver.getVersion(), subject.getDescription());
PooledConnection con = subject.getPooledConnection();
Assert.assertNotNull(con);
ICloudSpannerConnection connection = (ICloudSpannerConnection) con.getConnection();
Assert.assertEquals("jdbc:cloudspanner://localhost", connection.getUrl());
Assert.assertEquals("PostgreSQL", connection.getProductName());
Assert.assertEquals("helpful-adroit-123456", connection.getSuppliedProperties().getProperty("Project"));
Assert.assertEquals("test-instance", connection.getSuppliedProperties().getProperty("Instance"));
Assert.assertEquals("test", connection.getSuppliedProperties().getProperty("Database"));
Assert.assertEquals("TEST", connection.getSuppliedProperties().getProperty("OAuthAccessToken"));
Assert.assertTrue(connection.isAllowExtendedMode());
Assert.assertEquals(subject.isDefaultAutoCommit(), connection.getAutoCommit());
PooledConnection con2 = subject.getPooledConnection("TEST", "TEST");
Assert.assertNotNull(con2);
boolean exception = false;
try {
subject.getParentLogger();
} catch (SQLFeatureNotSupportedException e) {
exception = true;
}
Assert.assertTrue(exception);
}
Aggregations