Example usage for javax.sql ConnectionPoolDataSource getLogWriter

List of usage examples for javax.sql ConnectionPoolDataSource getLogWriter

Introduction

In this page you can find the example usage for javax.sql ConnectionPoolDataSource getLogWriter.

Prototype

@Override
java.io.PrintWriter getLogWriter() throws SQLException;

Source Link

Usage

From source file:biz.source_code.miniConnectionPoolManager.TestMiniConnectionPoolManager.java

/**
    * Constructs a MiniConnectionPoolManager object.
    * @param dataSource      the data source for the connections.
    * @param maxConnections  the maximum number of connections.
    * @param timeout         the maximum time in seconds to wait for a free connection.
    *//*from   w  w w. j  a  v a2  s . com*/
    public MiniConnectionPoolManager(ConnectionPoolDataSource dataSource, int maxConnections, int timeout) {
        this.dataSource = dataSource;
        this.maxConnections = maxConnections;
        this.timeout = timeout;
        try {
            logWriter = dataSource.getLogWriter();
        } catch (SQLException e) {
        }
        if (maxConnections < 1)
            throw new IllegalArgumentException("Invalid maxConnections value.");
        semaphore = new Semaphore(maxConnections, true);
        recycledConnections = new Stack<PooledConnection>();
        poolConnectionEventListener = new PoolConnectionEventListener();
    }

From source file:com.alibaba.wasp.jdbcx.JdbcConnectionPool.java

protected JdbcConnectionPool(ConnectionPoolDataSource dataSource, Configuration conf) {
    this.dataSource = dataSource;
    this.conf = conf;
    this.maxConnections = conf.getInt(FConstants.JDBC_POOL_MAX_CONNECTIONS,
            FConstants.DEFAULT_JDBC_POOL_MAX_CONNECTIONS);
    this.timeout = conf.getInt(FConstants.JDBC_CONNECTION_TIMEOUT, FConstants.DEFAULT_JDBC_CONNECTION_TIMEOUT);
    if (dataSource != null) {
        try {//from  w w w.  ja v a2s  .  c o m
            logWriter = dataSource.getLogWriter();
        } catch (SQLException e) {
            // ignore
        }
    }
}