本文整理匯總了Java中javax.sql.ConnectionEvent.getSource方法的典型用法代碼示例。如果您正苦於以下問題:Java ConnectionEvent.getSource方法的具體用法?Java ConnectionEvent.getSource怎麽用?Java ConnectionEvent.getSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.sql.ConnectionEvent
的用法示例。
在下文中一共展示了ConnectionEvent.getSource方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: connectionErrorOccurred
import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
/**
*
* A fatal error has occurred and the connection cannot be used anymore.
* A close event from such a connection should be ignored. The connection should not be reused.
* A new connection will be created to replace the invalid connection, when the next client
* calls getConnection().
*/
public synchronized void connectionErrorOccurred(ConnectionEvent event) {
PooledConnection connection = (PooledConnection) event.getSource();
connection.removeConnectionEventListener(this);
this.connectionsInUse.remove(connection);
this.sessionConnectionWrappers.remove(connection);
logInfo(
"Fatal exception occurred on pooled connection. Connection is removed from pool: ");
logInfo(event.getSQLException());
closePhysically(connection, "closing invalid, removed connection.");
//notify threads waiting for connections or for the pool to close.
//one waiting thread can now create a new connection since the pool has space for a new connection.
//if a thread waits for the pool to close this could be the last unclosed connection in the pool.
this.notifyAll();
}
示例2: connectionClosed
import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
public synchronized void connectionClosed(ConnectionEvent event) {
PooledConnection connection = (PooledConnection) event.getSource();
this.connectionsInUse.remove(connection);
this.sessionConnectionWrappers.remove(connection);
if (!this.isPoolClosed) {
enqueue(connection);
logInfo("Connection returned to pool.");
} else {
closePhysically(connection, "closing returned connection.");
logInfo(
"Connection returned to pool was closed because pool is closed.");
this.notifyAll(); //notifies evt. threads waiting for connection or for the pool to close.
}
}
示例3: connectionClosed
import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
/**
* Implementation of call back function from ConnectionEventListener interface. This callback will
* be invoked on connection close event.
*
* @param event Connection event object
*/
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 occured due to " + e;
if (logger.isDebugEnabled()) {
logger.debug(exception, e);
}
}
}
}
示例4: connectionErrorOccurred
import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
/**
* Implementation of call back function from ConnectionEventListener interface. This callback will
* be invoked on connection error event.
*
* @param event
*/
public void connectionErrorOccurred(ConnectionEvent event) {
if (isActive) {
try {
PooledConnection conn = (PooledConnection) event.getSource();
provider.returnAndExpireConnection(conn);
} catch (Exception ex) {
String exception =
"GemFireConnPooledDataSource::connectionErrorOccured:error in returning and expiring connection due to "
+ ex;
if (logger.isDebugEnabled()) {
logger.debug(exception, ex);
}
}
}
}
示例5: connectionClosed
import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
@Override
public synchronized void connectionClosed(ConnectionEvent event)
{
PooledCassandraConnection connection = (PooledCassandraConnection) event.getSource();
usedConnections.remove(connection);
int freeConnectionsCount = freeConnections.size();
if (freeConnectionsCount < MIN_POOL_SIZE)
{
freeConnections.add(connection);
}
else
{
try
{
connection.close();
}
catch (SQLException e)
{
logger.error(e.getMessage());
}
}
}
示例6: connectionErrorOccurred
import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
@Override
public synchronized void connectionErrorOccurred(ConnectionEvent event)
{
PooledCassandraConnection connection = (PooledCassandraConnection) event.getSource();
try
{
if (!connection.getConnection().isValid(CONNECTION_IS_VALID_TIMEOUT)) {
connection.getConnection().close();
}
}
catch (SQLException e)
{
logger.error(e.getMessage());
}
usedConnections.remove(connection);
}
示例7: connectionErrorOccurred
import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
/**
* If a fatal error occurs, close the underlying physical connection so as
* not to be returned in the future
*/
public void connectionErrorOccurred(ConnectionEvent event) {
PooledConnection pc = (PooledConnection)event.getSource();
if (null != event.getSQLException()) {
System.err
.println("CLOSING DOWN CONNECTION DUE TO INTERNAL ERROR (" +
event.getSQLException() + ")");
}
pc.removeConnectionEventListener(this);
PooledConnectionAndInfo info = (PooledConnectionAndInfo) pcMap.get(pc);
if (info == null) {
throw new IllegalStateException(NO_KEY_MESSAGE);
}
try {
_pool.invalidateObject(info.getUserPassKey(), info);
} catch (Exception e) {
System.err.println("EXCEPTION WHILE DESTROYING OBJECT " + info);
e.printStackTrace();
}
}
示例8: connectionErrorOccurred
import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
/**
* If a fatal error occurs, close the underlying physical connection so as
* not to be returned in the future
*/
public void connectionErrorOccurred(ConnectionEvent event) {
PooledConnection pc = (PooledConnection)event.getSource();
if (null != event.getSQLException()) {
System.err.println(
"CLOSING DOWN CONNECTION DUE TO INTERNAL ERROR ("
+ event.getSQLException() + ")");
}
pc.removeConnectionEventListener(this);
Object info = pcMap.get(pc);
if (info == null) {
throw new IllegalStateException(NO_KEY_MESSAGE);
}
try {
_pool.invalidateObject(info);
} catch (Exception e) {
System.err.println("EXCEPTION WHILE DESTROYING OBJECT " + info);
e.printStackTrace();
}
}
示例9: connectionErrorOccurred
import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
/**
* If a fatal error occurs, close the underlying physical connection so as
* not to be returned in the future
*/
@Override
public void connectionErrorOccurred(final ConnectionEvent event) {
final PooledConnection pc = (PooledConnection)event.getSource();
if (null != event.getSQLException()) {
System.err
.println("CLOSING DOWN CONNECTION DUE TO INTERNAL ERROR (" +
event.getSQLException() + ")");
}
pc.removeConnectionEventListener(this);
final PooledConnectionAndInfo info = pcMap.get(pc);
if (info == null) {
throw new IllegalStateException(NO_KEY_MESSAGE);
}
try {
_pool.invalidateObject(info.getUserPassKey(), info);
} catch (final Exception e) {
System.err.println("EXCEPTION WHILE DESTROYING OBJECT " + info);
e.printStackTrace();
}
}
示例10: connectionErrorOccurred
import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
/**
* If a fatal error occurs, close the underlying physical connection so as
* not to be returned in the future
*/
@Override
public void connectionErrorOccurred(final ConnectionEvent event) {
final PooledConnection pc = (PooledConnection)event.getSource();
if (null != event.getSQLException()) {
System.err.println(
"CLOSING DOWN CONNECTION DUE TO INTERNAL ERROR ("
+ event.getSQLException() + ")");
}
pc.removeConnectionEventListener(this);
final PooledConnectionAndInfo pci = pcMap.get(pc);
if (pci == null) {
throw new IllegalStateException(NO_KEY_MESSAGE);
}
try {
_pool.invalidateObject(pci);
} catch (final Exception e) {
System.err.println("EXCEPTION WHILE DESTROYING OBJECT " + pci);
e.printStackTrace();
}
}
示例11: connectionClosed
import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
public void connectionClosed(ConnectionEvent event) {
PooledConnection connection = (PooledConnection) event.getSource();
for (int i = 0; i < connections.length; i++) {
if (connections[i] == connection) {
states.set(i, RefState.available);
break;
}
}
}
示例12: connectionErrorOccurred
import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
public void connectionErrorOccurred(ConnectionEvent event) {
PooledConnection connection = (PooledConnection) event.getSource();
for (int i = 0; i < connections.length; i++) {
if (connections[i] == connection) {
states.set(i, RefState.allocated);
connections[i] = null;
states.set(i, RefState.empty);
break;
}
}
}
示例13: connectionErrorOccurred
import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
/**
* 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::connectionErrorOccured: Exception occured due to " + ex;
if (logger.isDebugEnabled()) {
logger.debug(exception, ex);
}
}
}
}
示例14: connectionClosed
import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
/**
* Implementation of call back function from ConnectionEventListener interface. This callback will
* be invoked on connection close event.
*
* @param event
*/
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);
}
}
}
}
示例15: connectionClosed
import javax.sql.ConnectionEvent; //導入方法依賴的package包/類
/**
* INTERNAL
*/
@Override
public void connectionClosed(ConnectionEvent event) {
PooledConnection pc = (PooledConnection) event.getSource();
pc.removeConnectionEventListener(this);
recycleConnection(pc);
}