All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alterioncorp.perfjdbc.sql.PerfConnectionPoolDataSource Maven / Gradle / Ivy

Go to download

Wrapper JDBC driver that monitors time spent inside JDBC code by thread. JDBC driver URL: jdbc:alterion:perf://class=<TARGET_DRIVER_CLASS>|url=<TARGET_JDBC_URL> To get the time in millis spent inside JDBC for thread: StopWatch.getTime()

The newest version!
package com.alterioncorp.perfjdbc.sql;

import java.sql.SQLException;

import javax.sql.ConnectionPoolDataSource;
import javax.sql.PooledConnection;

import com.alterioncorp.perfjdbc.PerfProxy;
import com.alterioncorp.perfjdbc.PerfProxyFactory;
import com.alterioncorp.perfjdbc.StopWatch;

public class PerfConnectionPoolDataSource extends PerfCommonDataSource
		implements ConnectionPoolDataSource, PerfProxy {

	public PerfConnectionPoolDataSource() {
		super();
	}

	public PerfConnectionPoolDataSource(ConnectionPoolDataSource targetDataSource) {
		super(targetDataSource);
	}

	public PerfConnectionPoolDataSource(String targetJndi) {
		super(targetJndi);
	}

	@Override
	public PooledConnection getPooledConnection() throws SQLException {
		StopWatch.start();
		try {
			return PerfProxyFactory.createProxy(
					PooledConnection.class,
					this.getTargetConnectionPoolDataSource().getPooledConnection());
		}
		finally {
			StopWatch.stop();
		}
	}

	@Override
	public PooledConnection getPooledConnection(String user, String password)
			throws SQLException {
		StopWatch.start();
		try {
			return PerfProxyFactory.createProxy(
					PooledConnection.class,
					this.getTargetConnectionPoolDataSource().getPooledConnection(user, password));
		}
		finally {
			StopWatch.stop();
		}
	}

	protected final ConnectionPoolDataSource getTargetConnectionPoolDataSource() {
		return (ConnectionPoolDataSource)this.getTargetCommonDataSource();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy