@Override
	public Connection connect(String url, Properties info) throws SQLException {
		if ("false".equals(info.get("javamelody"))) {
			// if property javamelody=false then it's not for us
			// (we pass here from the DriverManager.getConnection below)
			return null;
		}
		String myUrl = url;
		// we load first the driver class from the info or the url, to be sure that it will be found
		String proxiedDriver = info.getProperty("driver");
		if (proxiedDriver == null && myUrl != null) {
			// if not in the info, the driver class could also be passed at the end of the url, for example ...?driver=org.h2.Driver
			final int index = myUrl.indexOf("driver=");
			if (index != -1) {
				proxiedDriver = myUrl.substring(index + "driver=".length());
				myUrl = myUrl.substring(0, index - 1);
			}
		}
		if (proxiedDriver == null) {
			// if the driver is not defined in the info or in the url
			// it could still be found automatically if the driver is in the classpath
			// or (in WEB-INF/lib and if the jdbc drivers are not loaded by the JDK before this webapp)
			// but we don't want to create proxies and increment counts for the connections inside datasources
			// so we only accept and go further if driver is defined in the info or in the url
			return null;
		}
		try {
			// on utilise Thread.currentThread().getContextClassLoader() car le driver peut ne pas être
			// dans le même classLoader que les classes de javamelody
			// Class driverClass =
			Class.forName(proxiedDriver, true, Thread.currentThread().getContextClassLoader());
			// et non Class.forName(proxiedDriver);
		} 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);
		// we could call driverClass.newInstance().connect(myUrl, myInfo)
		// possibly by looking the driver which accepts the url in DriverManager.getDrivers()
		// but we prefer calling the standard DriverManager.getConnection(myUrl, myInfo)
		return JdbcWrapper.SINGLETON
				.createConnectionProxy(DriverManager.getConnection(myUrl, myInfo));
	}
@Test
	public void testConnect() throws SQLException {
		final Properties info = new Properties();
		try {
			driver.connect(null, info);
		} catch (final SQLException e) {
			// SQLException normale : The url cannot be null
			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) {
			// SQLException normale : class not found
			assertNotNull("connect", e);
		}
	}