Example usage for org.apache.commons.dbcp2 PoolableConnection clearWarnings

List of usage examples for org.apache.commons.dbcp2 PoolableConnection clearWarnings

Introduction

In this page you can find the example usage for org.apache.commons.dbcp2 PoolableConnection clearWarnings.

Prototype

void clearWarnings() throws SQLException;

Source Link

Usage

From source file:JDBCPool.dbcp.demo.sourcecode.PoolableConnectionFactory.java

@Override
public void passivateObject(PooledObject<PoolableConnection> p) throws Exception {

    validateLifetime(p);//from w w  w  .j  ava 2 s .  c  o  m

    PoolableConnection conn = p.getObject();
    Boolean connAutoCommit = null;
    if (rollbackOnReturn) {
        connAutoCommit = Boolean.valueOf(conn.getAutoCommit());
        if (!connAutoCommit.booleanValue() && !conn.isReadOnly()) {
            conn.rollback();
        }
    }

    conn.clearWarnings();

    // DBCP-97 / DBCP-399 / DBCP-351 Idle connections in the pool should
    // have autoCommit enabled
    if (enableAutoCommitOnReturn) {
        if (connAutoCommit == null) {
            connAutoCommit = Boolean.valueOf(conn.getAutoCommit());
        }
        if (!connAutoCommit.booleanValue()) {
            conn.setAutoCommit(true);
        }
    }

    conn.passivate();
}