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 File: PreparedStatementWrapper.java    From lams with 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 File: JDBC4PreparedStatementWrapper.java    From r-course with 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 File: JDBC4PreparedStatementWrapper.java    From Komondor with 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 File: PreparedStatementWrapper.java    From FoxTelem with 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 File: PooledCassandraConnection.java    From cassandra-jdbc-wrapper with 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 File: PooledCassandraConnection.java    From cassandra-jdbc-wrapper with 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 File: StatementHandler.java    From clearpool with 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 File: MysqlPooledConnection.java    From lams with 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 File: JDBC4MysqlXAConnection.java    From r-course with 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 File: JDBC4SuspendableXAConnection.java    From r-course with 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 File: JDBC4MysqlPooledConnection.java    From r-course with 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 File: JDBC4MysqlXAConnection.java    From Komondor with 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 File: JDBC4SuspendableXAConnection.java    From Komondor with 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 File: JDBC4MysqlPooledConnection.java    From Komondor with 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 File: ClientPooledConnection40.java    From gemfirexd-oss with 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 File: ClientXAConnection40.java    From gemfirexd-oss with 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 File: EmbedPooledConnection40.java    From gemfirexd-oss with 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 File: EmbedPooledConnection40.java    From gemfirexd-oss with 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 File: EmbedXAConnection40.java    From gemfirexd-oss with 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 File: EmbedXAConnection40.java    From gemfirexd-oss with 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 File: MysqlPooledConnection.java    From FoxTelem with 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 File: ClientPooledConnection40.java    From gemfirexd-oss with 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 File: ClientXAConnection40.java    From gemfirexd-oss with 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 File: EmbedPooledConnection40.java    From gemfirexd-oss with 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 File: EmbedPooledConnection40.java    From gemfirexd-oss with 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 File: EmbedXAConnection40.java    From gemfirexd-oss with 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 File: EmbedXAConnection40.java    From gemfirexd-oss with 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 File: XAConnectionImpl.java    From ByteJTA with 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 File: XAConnectionImpl.java    From ByteJTA with 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 File: StatementHandler.java    From clearpool with 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;
}