javax.sql.StatementEventListener Java Examples

The following examples show how to use javax.sql.StatementEventListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: cassandra-jdbc-wrapper   Author: adejanovski   File: PooledCassandraConnection.java    License: Apache License 2.0 6 votes vote down vote up
void statementErrorOccurred(CassandraPreparedStatement preparedStatement, SQLException sqlException)
{
	StatementEvent event = new StatementEvent(this, preparedStatement, sqlException);
	for (StatementEventListener listener : statementEventListeners)
	{
		listener.statementErrorOccurred(event);
	}
	
	String cql = preparedStatement.getCql();
	Set<CassandraPreparedStatement> usedStatements = usedPreparedStatements.get(cql);
	
	if (!(event.getSQLException() instanceof SQLRecoverableException))
	{
		preparedStatement.close();
		usedStatements.remove(preparedStatement);
	}
}
 
Example #2
Source Project: FHIR   Author: IBM   File: RMXAConnectionResource.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void addStatementEventListener(StatementEventListener listener) {
    log.entering(this.getClass().getName(), "addStatementEventListener");
    try {
        // Drive the method calls to each of the proxied XAConnections.
        List<XAConnection> connections = getProxiedXAConnections();
        for (XAConnection connection : connections) {
            connection.addStatementEventListener(listener);
        }
    } finally {
        log.exiting(this.getClass().getName(), "addStatementEventListener");
    }
}
 
Example #3
Source Project: spliceengine   Author: splicemachine   File: ClientPooledConnection40.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 *
 * Raise the statementClosed event for all the listeners when the 
 * corresponding events occurs.
 *
 * @param statement The PreparedStatement that was closed
 *
 */
public void onStatementClose(PreparedStatement statement) {
    if (!statementEventListeners.isEmpty()) {
        StatementEvent event = new StatementEvent(this,statement);
        for (StatementEventListener l : statementEventListeners) {
            l.statementClosed(event);
        }
    }
}
 
Example #4
Source Project: clearpool   Author: xionghuiCoder   File: PoolConnectionImpl.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void addStatementEventListener(StatementEventListener listener) {
  if (this.statementEventListeners == null) {
    this.statementEventListeners = new ArrayList<StatementEventListener>();
  }
  this.statementEventListeners.add(listener);
}
 
Example #5
Source Project: ByteJTA   Author: liuyangming   File: XAConnectionImpl.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
public void statementClosed(StatementEvent event) {
	Iterator<StatementEventListener> itr = this.statementEventListeners.iterator();
	while (itr.hasNext()) {
		StatementEventListener listener = itr.next();
		SQLException sqlException = event.getSQLException();
		PreparedStatement statement = event.getStatement();
		StatementEvent statementEvent = new StatementEvent(this, statement, sqlException);
		try {
			listener.statementClosed(statementEvent);
		} catch (RuntimeException error) {
			logger.warn("Error occurred!", error);
		}
	} // end-while (itr.hasNext())
}
 
Example #6
Source Project: r-course   Author: joanby   File: JDBC4MysqlPooledConnection.java    License: MIT License 5 votes vote down vote up
void fireStatementEvent(StatementEvent event) throws SQLException {
    synchronized (this.statementEventListeners) {
        for (StatementEventListener listener : this.statementEventListeners.keySet()) {
            listener.statementClosed(event);
        }
    }
}
 
Example #7
Source Project: Komondor   Author: wn-upf   File: JDBC4MysqlXAConnection.java    License: GNU General Public License v3.0 5 votes vote down vote up
void fireStatementEvent(StatementEvent event) throws SQLException {
    synchronized (this.statementEventListeners) {
        for (StatementEventListener listener : this.statementEventListeners.keySet()) {
            listener.statementClosed(event);
        }
    }
}
 
Example #8
Source Project: spliceengine   Author: splicemachine   File: EmbedPooledConnection40.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Raise the statementErrorOccurred event for all the listeners when the
 * corresponding events occurs
 * @param statement PreparedStatement
 * @param sqle      SQLException
 */
public void onStatementErrorOccurred(PreparedStatement statement,SQLException sqle) {
    if (!statementEventListeners.isEmpty()){
        StatementEvent event = new StatementEvent(this,statement,sqle);
        for (StatementEventListener l : statementEventListeners) {
            l.statementErrorOccurred(event);
        }
    }
}
 
Example #9
Source Project: Komondor   Author: wn-upf   File: JDBC4SuspendableXAConnection.java    License: GNU General Public License v3.0 5 votes vote down vote up
void fireStatementEvent(StatementEvent event) throws SQLException {
    synchronized (this.statementEventListeners) {
        for (StatementEventListener listener : this.statementEventListeners.keySet()) {
            listener.statementClosed(event);
        }
    }
}
 
Example #10
Source Project: Komondor   Author: wn-upf   File: JDBC4MysqlPooledConnection.java    License: GNU General Public License v3.0 5 votes vote down vote up
void fireStatementEvent(StatementEvent event) throws SQLException {
    synchronized (this.statementEventListeners) {
        for (StatementEventListener listener : this.statementEventListeners.keySet()) {
            listener.statementClosed(event);
        }
    }
}
 
Example #11
Source Project: gemfirexd-oss   Author: gemxd   File: ClientPooledConnection40.java    License: Apache License 2.0 5 votes vote down vote up
/**
 *
 * Raise the statementClosed event for all the listeners when the 
 * corresponding events occurs.
 *
 * @param statement The PreparedStatement that was closed
 *
 */
public void onStatementClose(PreparedStatement statement) {
    if (!statementEventListeners.isEmpty()) {
        StatementEvent event = new StatementEvent(this,statement);
        for (StatementEventListener l : statementEventListeners) {
            l.statementClosed(event);
        }
    }
}
 
Example #12
Source Project: gemfirexd-oss   Author: gemxd   File: ClientXAConnection40.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Raise the statementClosed event for all the listeners when the 
 * corresponding events occurs
 * @param statement The PreparedStatement that was closed
 */
public void onStatementClose(PreparedStatement statement) {
    if (!statementEventListeners.isEmpty()) {
        StatementEvent event = new StatementEvent(this,statement);
        for (StatementEventListener l : statementEventListeners) {
            l.statementClosed(event);
        }
    }
}
 
Example #13
Source Project: gemfirexd-oss   Author: gemxd   File: EmbedPooledConnection40.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Raise the statementClosed event for all the listeners when the
 * corresponding events occurs
 * @param statement PreparedStatement
 */
public void onStatementClose(PreparedStatement statement) {
    if (!statementEventListeners.isEmpty()){
        StatementEvent event = new StatementEvent(this,statement);
        for (StatementEventListener l : statementEventListeners) {
            l.statementClosed(event);
        }
    }
}
 
Example #14
Source Project: gemfirexd-oss   Author: gemxd   File: EmbedXAConnection40.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Raise the statementClosed event for all the listeners when the
 * corresponding events occurs
 * @param statement PreparedStatement
 */
public void onStatementClose(PreparedStatement statement) {
    if (!statementEventListeners.isEmpty()){
        StatementEvent event = new StatementEvent(this,statement);
        for (StatementEventListener l : statementEventListeners) {
            l.statementClosed(event);
        }
    }
}
 
Example #15
Source Project: gemfirexd-oss   Author: gemxd   File: EmbedXAConnection40.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Raise the statementErrorOccurred event for all the listeners when the
 * corresponding events occurs
 * @param statement PreparedStatement
 * @param sqle      SQLException
 */
public void onStatementErrorOccurred(PreparedStatement statement,SQLException sqle) {
    if (!statementEventListeners.isEmpty()){
        StatementEvent event = new StatementEvent(this,statement,sqle);
        for (StatementEventListener l : statementEventListeners) {
            l.statementErrorOccurred(event);
        }
    }
}
 
Example #16
Source Project: FoxTelem   Author: ac2cz   File: MysqlPooledConnection.java    License: GNU General Public License v3.0 5 votes vote down vote up
void fireStatementEvent(StatementEvent event) throws SQLException {
    synchronized (this.statementEventListeners) {
        for (StatementEventListener listener : this.statementEventListeners.keySet()) {
            listener.statementClosed(event);
        }
    }
}
 
Example #17
Source Project: ByteJTA   Author: liuyangming   File: XAConnectionImpl.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
public void statementErrorOccurred(StatementEvent event) {
	Iterator<StatementEventListener> itr = this.statementEventListeners.iterator();
	while (itr.hasNext()) {
		StatementEventListener listener = itr.next();
		SQLException sqlException = event.getSQLException();
		PreparedStatement statement = event.getStatement();
		StatementEvent statementEvent = new StatementEvent(this, statement, sqlException);
		try {
			listener.statementErrorOccurred(statementEvent);
		} catch (RuntimeException error) {
			logger.warn("Error occurred!", error);
		}
	} // end-while (itr.hasNext())
}
 
Example #18
Source Project: clearpool   Author: xionghuiCoder   File: StatementHandler.java    License: GNU General Public License v3.0 5 votes vote down vote up
private SQLException handleException(SQLException e) throws SQLException {
  if (this.statement instanceof PreparedStatement) {
    List<StatementEventListener> statementEventListeners =
        this.pooledConnection.getStatementEventListeners();
    if (statementEventListeners != null) {
      StatementEvent event =
          new StatementEvent(this.pooledConnection, (PreparedStatement) this.statement);
      for (StatementEventListener listener : statementEventListeners) {
        listener.statementErrorOccurred(event);
      }
    }
  }
  throw e;
}
 
Example #19
Source Project: gemfirexd-oss   Author: gemxd   File: EmbedPooledConnection40.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Raise the statementClosed event for all the listeners when the
 * corresponding events occurs
 * @param statement PreparedStatement
 */
public void onStatementClose(PreparedStatement statement) {
    if (!statementEventListeners.isEmpty()){
        StatementEvent event = new StatementEvent(this,statement);
        for (StatementEventListener l : statementEventListeners) {
            l.statementClosed(event);
        }
    }
}
 
Example #20
Source Project: gemfirexd-oss   Author: gemxd   File: EmbedPooledConnection40.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Raise the statementErrorOccurred event for all the listeners when the
 * corresponding events occurs
 * @param statement PreparedStatement
 * @param sqle      SQLException
 */
public void onStatementErrorOccurred(PreparedStatement statement,SQLException sqle) {
    if (!statementEventListeners.isEmpty()){
        StatementEvent event = new StatementEvent(this,statement,sqle);
        for (StatementEventListener l : statementEventListeners) {
            l.statementErrorOccurred(event);
        }
    }
}
 
Example #21
Source Project: gemfirexd-oss   Author: gemxd   File: EmbedXAConnection40.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Raise the statementClosed event for all the listeners when the
 * corresponding events occurs
 * @param statement PreparedStatement
 */
public void onStatementClose(PreparedStatement statement) {
    if (!statementEventListeners.isEmpty()){
        StatementEvent event = new StatementEvent(this,statement);
        for (StatementEventListener l : statementEventListeners) {
            l.statementClosed(event);
        }
    }
}
 
Example #22
Source Project: spliceengine   Author: splicemachine   File: ClientXAConnection40.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Raise the statementClosed event for all the listeners when the 
 * corresponding events occurs
 * @param statement The PreparedStatement that was closed
 */
public void onStatementClose(PreparedStatement statement) {
    if (!statementEventListeners.isEmpty()) {
        StatementEvent event = new StatementEvent(this,statement);
        for (StatementEventListener l : statementEventListeners) {
            l.statementClosed(event);
        }
    }
}
 
Example #23
Source Project: Tomcat8-Source-Read   Author: chenmudu   File: PooledConnectionImpl.java    License: MIT License 4 votes vote down vote up
@Override
public void addStatementEventListener(final StatementEventListener listener) {
    if (!statementEventListeners.contains(listener)) {
        statementEventListeners.add(listener);
    }
}
 
Example #24
Source Project: Tomcat8-Source-Read   Author: chenmudu   File: PooledConnectionImpl.java    License: MIT License 4 votes vote down vote up
@Override
public void removeStatementEventListener(final StatementEventListener listener) {
    statementEventListeners.remove(listener);
}
 
Example #25
Source Project: spliceengine   Author: splicemachine   File: ClientPooledConnection.java    License: GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void addStatementEventListener(StatementEventListener listener){
    throw new UnsupportedOperationException();
}
 
Example #26
Source Project: commons-dbcp   Author: apache   File: PooledConnectionProxy.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void removeStatementEventListener(final StatementEventListener listener) {
    eventListeners.remove(listener);
}
 
Example #27
Source Project: ByteJTA   Author: liuyangming   File: XAConnectionImpl.java    License: GNU Lesser General Public License v3.0 4 votes vote down vote up
public void addStatementEventListener(StatementEventListener listener) {
	this.statementEventListeners.add(listener);
}
 
Example #28
Source Project: carbon-commons   Author: wso2   File: LocalXADataSource.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void removeStatementEventListener(StatementEventListener listener) {
    //ignore
}
 
Example #29
Source Project: nh-micro   Author: jeffreyning   File: MicroPooledConnection.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void addStatementEventListener(StatementEventListener listener) {
	// TODO Auto-generated method stub
	
}
 
Example #30
Source Project: spliceengine   Author: splicemachine   File: EmbedPooledConnection.java    License: GNU Affero General Public License v3.0 4 votes vote down vote up
public void removeStatementEventListener(StatementEventListener listener){
	throw new UnsupportedOperationException();
}