/** * Parses out the real JDBC connection URL by removing "p6spy:". * * @param url the connection URL * @return the parsed URL */ private String extractRealUrl(String url) { return acceptsURL(url) ? url.replace("p6spy:", "") : url; }
protected Driver findPassthru(String url) throws SQLException { // registers the passthru drivers, if configured s P6ModuleManager.getInstance(); String realUrl = extractRealUrl(url); Driver passthru = null; for (Driver driver: registeredDrivers() ) { try { if (driver.acceptsURL(extractRealUrl(url))) { passthru = driver; break; } } catch (SQLException e) { } } if( passthru == null ) { throw new SQLException("Unable to find a driver that accepts " + realUrl); } return passthru; }
@Override public DriverPropertyInfo[] getPropertyInfo(String url, Properties properties) throws SQLException { return findPassthru(url).getPropertyInfo(url, properties); }
if( !acceptsURL(url) ) { return null; Driver passThru = findPassthru(url); jdbcEventListener.onBeforeGetConnection(connectionInformation); try { conn = passThru.connect(extractRealUrl(url), properties); connectionInformation.setConnection(conn); connectionInformation.setTimeToGetConnectionNs(System.nanoTime() - start);
@After public void after() throws Exception { P6TestFactory.setJdbcEventListener(null); P6SpyDriver.setJdbcEventListenerFactory(null); }
@Test public void testVersion() throws Exception { Driver driver = new P6SpyDriver(); assertEquals(2, driver.getMajorVersion()); assertEquals(0, driver.getMinorVersion()); }
if( !acceptsURL(url) ) { return null; Driver passThru = findPassthru(url); jdbcEventListener.onBeforeGetConnection(connectionInformation); try { conn = passThru.connect(extractRealUrl(url), properties); connectionInformation.setConnection(conn); connectionInformation.setTimeToGetConnectionNs(System.nanoTime() - start);
mockedJdbcListener); P6SpyDriver.setJdbcEventListenerFactory(new JdbcEventListenerFactory() { @Override public JdbcEventListener createJdbcEventListener() {
protected Driver findPassthru(String url) throws SQLException { // registers the passthru drivers, if configured s P6ModuleManager.getInstance(); String realUrl = extractRealUrl(url); Driver passthru = null; for (Driver driver: registeredDrivers() ) { try { if (driver.acceptsURL(extractRealUrl(url))) { passthru = driver; break; } } catch (SQLException e) { } } if( passthru == null ) { throw new SQLException("Unable to find a driver that accepts " + realUrl); } return passthru; }
/** * Parses out the real JDBC connection URL by removing "p6spy:". * * @param url the connection URL * @return the parsed URL */ private String extractRealUrl(String url) { return acceptsURL(url) ? url.replace("p6spy:", "") : url; }
@Override public DriverPropertyInfo[] getPropertyInfo(String url, Properties properties) throws SQLException { return findPassthru(url).getPropertyInfo(url, properties); }