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

com.alterioncorp.perfjdbc.sql.PerfDataSource 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.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;

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

public class PerfDataSource extends PerfCommonDataSource implements DataSource, PerfProxy {
	
	public PerfDataSource() {
		super();
	}
	
	public PerfDataSource(DataSource targetDataSource) {
		super(targetDataSource);
	}
	
	public PerfDataSource(String targetJndi) {
		super(targetJndi);
	}

	@Override
	public  T unwrap(Class iface) throws SQLException {
		return this.getTargetDataSource().unwrap(iface);
	}

	@Override
	public boolean isWrapperFor(Class iface) throws SQLException {
		return this.getTargetDataSource().isWrapperFor(iface);
	}

	@Override
	public Connection getConnection() throws SQLException {
		StopWatch.start();
		try {
			return PerfProxyFactory.createProxy(
					Connection.class,
					this.getTargetDataSource().getConnection());
		}
		finally {
			StopWatch.stop();
		}
	}

	@Override
	public Connection getConnection(String username, String password)
			throws SQLException {
		StopWatch.start();
		try {
			return PerfProxyFactory.createProxy(
					Connection.class,
					this.getTargetDataSource().getConnection(username, password));
		}
		finally {
			StopWatch.stop();
		}
	}

	protected final DataSource getTargetDataSource() {
		return (DataSource)this.getTargetCommonDataSource();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy