本文整理了Java中javax.sql.ConnectionEvent.getSource()
方法的一些代码示例,展示了ConnectionEvent.getSource()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ConnectionEvent.getSource()
方法的具体详情如下:
包路径:javax.sql.ConnectionEvent
类名称:ConnectionEvent
方法名:getSource
暂无
代码示例来源:origin: org.postgresql/postgresql
public void connectionClosed(ConnectionEvent event) {
((PooledConnection) event.getSource()).removeConnectionEventListener(this);
synchronized (lock) {
if (available == null) {
return; // DataSource has been closed
}
boolean removed = used.remove(event.getSource());
if (removed) {
available.push((PooledConnection) event.getSource());
// There's now a new connection available
lock.notify();
} else {
// a connection error occurred
}
}
}
代码示例来源:origin: org.postgresql/postgresql
/**
* This is only called for fatal errors, where the physical connection is useless afterward and
* should be removed from the pool.
*/
public void connectionErrorOccurred(ConnectionEvent event) {
((PooledConnection) event.getSource()).removeConnectionEventListener(this);
synchronized (lock) {
if (available == null) {
return; // DataSource has been closed
}
used.remove(event.getSource());
// We're now at least 1 connection under the max
lock.notify();
}
}
};
代码示例来源:origin: postgresql/postgresql
/**
* This is only called for fatal errors, where the physical connection is
* useless afterward and should be removed from the pool.
*/
public void connectionErrorOccurred(ConnectionEvent event)
{
((PooledConnection) event.getSource()).removeConnectionEventListener(this);
synchronized (lock )
{
if (available == null)
{
return ; // DataSource has been closed
}
used.remove(event.getSource());
// We're now at least 1 connection under the max
lock.notify();
}
}
};
代码示例来源:origin: postgresql/postgresql
public void connectionClosed(ConnectionEvent event)
{
((PooledConnection)event.getSource()).removeConnectionEventListener(this);
synchronized (lock )
{
if (available == null)
{
return ; // DataSource has been closed
}
boolean removed = used.remove(event.getSource());
if (removed)
{
available.push(event.getSource());
// There's now a new connection available
lock.notify();
}
else
{
// a connection error occured
}
}
}
代码示例来源:origin: apache/geode
/**
* Implementation of call back function from ConnectionEventListener interface. This callback will
* be invoked on connection close event.
*
*/
@Override
public void connectionClosed(ConnectionEvent event) {
if (isActive) {
try {
PooledConnection conn = (PooledConnection) event.getSource();
provider.returnConnection(conn);
} catch (Exception ex) {
String exception = "GemFireConnPooledDataSource::connectionclosed:Exception =" + ex;
if (logger.isDebugEnabled()) {
logger.debug(exception, ex);
}
}
}
}
代码示例来源:origin: apache/geode
/**
* Implementation of call back function from ConnectionEventListener interface. This callback will
* be invoked on connection error event.
*
*/
@Override
public void connectionErrorOccurred(ConnectionEvent event) {
if (isActive) {
try {
PooledConnection conn = (PooledConnection) event.getSource();
provider.returnAndExpireConnection(conn);
} catch (Exception ex) {
String exception =
"GemFireConnPooledDataSource::connectionErrorOccurred:error in returning and expiring connection due to "
+ ex;
if (logger.isDebugEnabled()) {
logger.debug(exception, ex);
}
}
}
}
代码示例来源:origin: com.h2database/h2
/**
* INTERNAL
*/
@Override
public void connectionClosed(ConnectionEvent event) {
PooledConnection pc = (PooledConnection) event.getSource();
pc.removeConnectionEventListener(this);
recycleConnection(pc);
}
代码示例来源:origin: apache/geode
/**
* Implementation of call back function from ConnectionEventListener interface. This callback will
* be invoked on connection error event.
*
* @param event Connection event object
*/
@Override
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);
}
}
}
}
代码示例来源:origin: apache/geode
/**
* Implementation of call back function from ConnectionEventListener interface. This callback will
* be invoked on connection close event.
*
* @param event Connection event object
*/
@Override
public void connectionClosed(ConnectionEvent event) {
if (isActive) {
try {
XAConnection conn = (XAConnection) event.getSource();
XAResource xar = (XAResource) xaResourcesMap.get(conn);
xaResourcesMap.remove(conn);
Transaction txn = transManager.getTransaction();
if (txn != null && xar != null)
txn.delistResource(xar, XAResource.TMSUCCESS);
provider.returnConnection(conn);
} catch (Exception e) {
String exception =
"GemFireTransactionDataSource::connectionClosed: Exception occurred due to " + e;
if (logger.isDebugEnabled()) {
logger.debug(exception, e);
}
}
}
}
代码示例来源:origin: caskdata/cdap
@Override
public void connectionErrorOccurred (ConnectionEvent event) {
PooledConnection pconn = (PooledConnection) event.getSource();
disposeConnection(pconn);
}
}
代码示例来源:origin: co.cask.cdap/cdap-common
@Override
public void connectionErrorOccurred (ConnectionEvent event) {
PooledConnection pconn = (PooledConnection) event.getSource();
disposeConnection(pconn);
}
}
代码示例来源:origin: caskdata/cdap
@Override
public void connectionClosed (ConnectionEvent event) {
PooledConnection pconn = (PooledConnection) event.getSource();
recycleConnection(pconn);
}
代码示例来源:origin: org.mariadb.jdbc/mariadb-java-client
@Override
public void connectionErrorOccurred(ConnectionEvent event) {
MariaDbPooledConnection item = ((MariaDbPooledConnection) event.getSource());
totalConnection.decrementAndGet();
silentCloseConnection(item);
logger.debug("connection removed from pool {} due to having throw a Connection exception",
poolTag);
}
代码示例来源:origin: org.apache.commons/commons-dbcp2
@Override
public void connectionClosed(final ConnectionEvent event) {
final PooledConnection pc = (PooledConnection) event.getSource();
pc.removeConnectionEventListener(this);
try {
pc.close();
} catch (final SQLException e) {
System.err.println("Failed to close XAConnection");
e.printStackTrace();
}
}
代码示例来源:origin: c3p0/c3p0
private void doCheckinResource(ConnectionEvent evt)
{
try
{ rp.checkinResource( evt.getSource() ); }
catch (Exception e)
{
//e.printStackTrace();
logger.log( MLevel.WARNING,
"An Exception occurred while trying to check a PooledConection into a ResourcePool.",
e );
}
}
代码示例来源:origin: com.mchange.c3p0/com.springsource.com.mchange.v2.c3p0
private void doCheckinResource(ConnectionEvent evt)
{
try
{ rp.checkinResource( evt.getSource() ); }
catch (Exception e)
{
//e.printStackTrace();
logger.log( MLevel.WARNING,
"An Exception occurred while trying to check a PooledConection into a ResourcePool.",
e );
}
}
代码示例来源:origin: com.eventsourcing/h2
/**
* INTERNAL
*/
@Override
public void connectionClosed(ConnectionEvent event) {
PooledConnection pc = (PooledConnection) event.getSource();
pc.removeConnectionEventListener(this);
recycleConnection(pc);
}
代码示例来源:origin: org.wowtools/h2
/**
* INTERNAL
*/
@Override
public void connectionClosed(ConnectionEvent event) {
PooledConnection pc = (PooledConnection) event.getSource();
pc.removeConnectionEventListener(this);
recycleConnection(pc);
}
代码示例来源:origin: xapool/xapool
/**
* Invoked when the application calls close()
* on its representation of the connection
*/
public void connectionClosed(ConnectionEvent event) {
log.debug("StandardPoolDataSource:connectionClosed close the connection");
Object obj = event.getSource();
pool.checkIn(obj);
}
代码示例来源:origin: com.atomikos/transactions-jdbc-deprecated
/**
* @see javax.sql.ConnectionEventListener#connectionClosed(javax.sql.ConnectionEvent)
*/
public void connectionClosed ( ConnectionEvent arg )
{
DTPPooledConnection pc = (DTPPooledConnection) arg.getSource ();
if ( pc.isDiscarded () ) {
pc.removeConnectionEventListener ( this );
pool_.putBack ( pc );
}
}
内容来源于网络,如有侵权,请联系作者删除!