@Test public void testConnect() throws SQLException { final Properties info = new Properties(); try { driver.connect(null, info); } catch (final SQLException e) { assertNotNull("connect", e); } driver.connect("jdbc:h2:mem:?driver=org.h2.Driver", info); info.put("driver", "org.h2.Driver"); driver.connect("jdbc:h2:mem:", info); info.put("driver", "nimporte.quoi"); try { driver.connect(null, info); } catch (final SQLException e) { assertNotNull("connect", e); } }
@Override public Connection connect(String url, Properties info) throws SQLException { if ("false".equals(info.get("javamelody"))) { return null; } String myUrl = url; String proxiedDriver = info.getProperty("driver"); if (proxiedDriver == null && myUrl != null) { final int index = myUrl.indexOf("driver="); if (index != -1) { proxiedDriver = myUrl.substring(index + "driver=".length()); myUrl = myUrl.substring(0, index - 1); } } if (proxiedDriver == null) { return null; } try { Class.forName(proxiedDriver, true, Thread.currentThread().getContextClassLoader()); } catch (final ClassNotFoundException e) { throw new SQLException(e.getMessage(), e); } final Properties myInfo = (Properties) info.clone(); myInfo.remove("driver"); myInfo.put("javamelody", "false"); Parameters.initJdbcDriverParameters(myUrl, myInfo); return JdbcWrapper.SINGLETON .createConnectionProxy(DriverManager.getConnection(myUrl, myInfo)); }
JdbcDriver implements Driver { @Override public Connection connect(String url, Properties info) throws SQLException { if ("false".equals(info.get("javamelody"))) { return null; } String myUrl = url; String proxiedDriver = info.getProperty("driver"); if (proxiedDriver == null && myUrl != null) { final int index = myUrl.indexOf("driver="); if (index != -1) { proxiedDriver = myUrl.substring(index + "driver=".length()); myUrl = myUrl.substring(0, index - 1); } } if (proxiedDriver == null) { return null; } try { Class.forName(proxiedDriver, true, Thread.currentThread().getContextClassLoader()); } catch (final ClassNotFoundException e) { throw new SQLException(e.getMessage(), e); } final Properties myInfo = (Properties) info.clone(); myInfo.remove("driver"); myInfo.put("javamelody", "false"); Parameters.initJdbcDriverParameters(myUrl, myInfo); return JdbcWrapper.SINGLETON .createConnectionProxy(DriverManager.getConnection(myUrl, myInfo)); } }
JdbcDriver implements Driver { @Override public Connection connect(String url, Properties info) throws SQLException { if ("false".equals(info.get("javamelody"))) { return null; } String myUrl = url; String proxiedDriver = info.getProperty("driver"); if (proxiedDriver == null && myUrl != null) { final int index = myUrl.indexOf("driver="); if (index != -1) { proxiedDriver = myUrl.substring(index + "driver=".length()); myUrl = myUrl.substring(0, index - 1); } } if (proxiedDriver == null) { return null; } try { Class.forName(proxiedDriver, true, Thread.currentThread().getContextClassLoader()); } catch (final ClassNotFoundException e) { throw new SQLException(e.getMessage(), e); } final Properties myInfo = (Properties) info.clone(); myInfo.remove("driver"); myInfo.put("javamelody", "false"); Parameters.initJdbcDriverParameters(myUrl, myInfo); return JdbcWrapper.SINGLETON .createConnectionProxy(DriverManager.getConnection(myUrl, myInfo)); }  }
JdbcDriver implements Driver { @Override public Connection connect(String url, Properties info) throws SQLException { if ("false".equals(info.get("javamelody"))) { return null; } String myUrl = url; String proxiedDriver = info.getProperty("driver"); if (proxiedDriver == null && myUrl != null) { final int index = myUrl.indexOf("driver="); if (index != -1) { proxiedDriver = myUrl.substring(index + "driver=".length()); myUrl = myUrl.substring(0, index - 1); } } if (proxiedDriver == null) { return null; } try { Class.forName(proxiedDriver, true, Thread.currentThread().getContextClassLoader()); } catch (final ClassNotFoundException e) { throw new SQLException(e.getMessage(), e); } final Properties myInfo = (Properties) info.clone(); myInfo.remove("driver"); myInfo.put("javamelody", "false"); Parameters.initJdbcDriverParameters(myUrl, myInfo); return JdbcWrapper.SINGLETON .createConnectionProxy(DriverManager.getConnection(myUrl, myInfo)); }  @Override Connection connect(String url, Properties info); @Override boolean acceptsURL(String url); @Override int getMajorVersion(); @Override int getMinorVersion(); @Override DriverPropertyInfo[] getPropertyInfo(String url, Properties info); @Override boolean jdbcCompliant(); @Override String toString(); @Override Logger getParentLogger(); }
JdbcDriver implements Driver { @Override public Connection connect(String url, Properties info) throws SQLException { if ("false".equals(info.get("javamelody"))) { return null; } String myUrl = url; String proxiedDriver = info.getProperty("driver"); if (proxiedDriver == null && myUrl != null) { final int index = myUrl.indexOf("driver="); if (index != -1) { proxiedDriver = myUrl.substring(index + "driver=".length()); myUrl = myUrl.substring(0, index - 1); } } if (proxiedDriver == null) { return null; } try { Class.forName(proxiedDriver, true, Thread.currentThread().getContextClassLoader()); } catch (final ClassNotFoundException e) { throw new SQLException(e.getMessage(), e); } final Properties myInfo = (Properties) info.clone(); myInfo.remove("driver"); myInfo.put("javamelody", "false"); Parameters.initJdbcDriverParameters(myUrl, myInfo); return JdbcWrapper.SINGLETON .createConnectionProxy(DriverManager.getConnection(myUrl, myInfo)); }  @Override Connection connect(String url, Properties info); @Override boolean acceptsURL(String url); @Override int getMajorVersion(); @Override int getMinorVersion(); @Override DriverPropertyInfo[] getPropertyInfo(String url, Properties info); @Override boolean jdbcCompliant(); @Override String toString(); @Override Logger getParentLogger();  }