javax.sql.StatementEvent Java Examples

The following examples show how to use javax.sql.StatementEvent. 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: lams   Author: lamsfoundation   File: PreparedStatementWrapper.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public synchronized void close() throws SQLException {
    if (this.pooledConnection == null) {
        // no-op
        return;
    }

    MysqlPooledConnection con = this.pooledConnection; // we need this later...

    try {
        super.close();
    } finally {
        try {
            StatementEvent e = new StatementEvent(con, this);
            con.fireStatementEvent(e);
        } finally {
            this.unwrappedInterfaces = null;
        }
    }
}
 
Example #2
Source Project: r-course   Author: joanby   File: JDBC4PreparedStatementWrapper.java    License: MIT License 6 votes vote down vote up
public synchronized void close() throws SQLException {
    if (this.pooledConnection == null) {
        // no-op
        return;
    }

    MysqlPooledConnection con = this.pooledConnection; // we need this later...

    try {
        super.close();
    } finally {
        try {
            StatementEvent e = new StatementEvent(con, this);
            // todo: pull this all up into base classes when we support *only* JDK6 or newer
            if (con instanceof JDBC4MysqlPooledConnection) {
                ((JDBC4MysqlPooledConnection) con).fireStatementEvent(e);
            } else if (con instanceof JDBC4MysqlXAConnection) {
                ((JDBC4MysqlXAConnection) con).fireStatementEvent(e);
            } else if (con instanceof JDBC4SuspendableXAConnection) {
                ((JDBC4SuspendableXAConnection) con).fireStatementEvent(e);
            }
        } finally {
            this.unwrappedInterfaces = null;
        }
    }
}
 
Example #3
Source Project: Komondor   Author: wn-upf   File: JDBC4PreparedStatementWrapper.java    License: GNU General Public License v3.0 6 votes vote down vote up
public synchronized void close() throws SQLException {
    if (this.pooledConnection == null) {
        // no-op
        return;
    }

    MysqlPooledConnection con = this.pooledConnection; // we need this later...

    try {
        super.close();
    } finally {
        try {
            StatementEvent e = new StatementEvent(con, this);
            // todo: pull this all up into base classes when we support *only* JDK6 or newer
            if (con instanceof JDBC4MysqlPooledConnection) {
                ((JDBC4MysqlPooledConnection) con).fireStatementEvent(e);
            } else if (con instanceof JDBC4MysqlXAConnection) {
                ((JDBC4MysqlXAConnection) con).fireStatementEvent(e);
            } else if (con instanceof JDBC4SuspendableXAConnection) {
                ((JDBC4SuspendableXAConnection) con).fireStatementEvent(e);
            }
        } finally {
            this.unwrappedInterfaces = null;
        }
    }
}
 
Example #4
Source Project: FoxTelem   Author: ac2cz   File: PreparedStatementWrapper.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public synchronized void close() throws SQLException {
    if (this.pooledConnection == null) {
        // no-op
        return;
    }

    MysqlPooledConnection con = this.pooledConnection; // we need this later...

    try {
        super.close();
    } finally {
        try {
            StatementEvent e = new StatementEvent(con, this);
            con.fireStatementEvent(e);
        } finally {
            this.unwrappedInterfaces = null;
        }
    }
}
 
Example #5
Source Project: cassandra-jdbc-wrapper   Author: adejanovski   File: PooledCassandraConnection.java    License: Apache License 2.0 6 votes vote down vote up
void statementClosed(CassandraPreparedStatement preparedStatement)
{
	StatementEvent event = new StatementEvent(this, preparedStatement);
	for (StatementEventListener listener : statementEventListeners)
	{
		listener.statementClosed(event);
	}

	String cql = preparedStatement.getCql();
	Set<CassandraPreparedStatement> freeStatements = freePreparedStatements.get(cql);
	Set<CassandraPreparedStatement> usedStatements = usedPreparedStatements.get(cql);

	usedStatements.remove(preparedStatement);
	
	preparedStatement.resetResults();
	try
	{
		preparedStatement.clearParameters();
		freeStatements.add(preparedStatement);
	}
	catch (SQLException e)
	{
		logger.error(e.getMessage());
	}

}
 
Example #6
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 #7
Source Project: clearpool   Author: xionghuiCoder   File: StatementHandler.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void close() throws SQLException {
  try {
    this.statement.close();
  } catch (SQLException e) {
    this.handleException(e);
  }
  this.pooledConnection.removeStatement(this.statement);
  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.statementClosed(event);
      }
    }
  }
}
 
Example #8
Source Project: lams   Author: lamsfoundation   File: MysqlPooledConnection.java    License: GNU General Public License v2.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 #9
Source Project: r-course   Author: joanby   File: JDBC4MysqlXAConnection.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 #10
Source Project: r-course   Author: joanby   File: JDBC4SuspendableXAConnection.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 #11
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 #12
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 #13
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 #14
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 #15
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 #16
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 #17
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 #18
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 #19
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 #20
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 #21
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 #22
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 #23
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 #24
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 #25
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 #26
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 #27
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 #28
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 #29
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 #30
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;
}