/*
 * Copyright 2017 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.glowroot.agent.sql;

import java.io.PrintStream;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.SQLException;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Properties;

import javax.annotation.Nullable;

public class DriverManager {

    private static volatile int loginTimeout;
    private static volatile @Nullable PrintWriter logWriter;
    private static volatile @Nullable PrintStream logStream;

    private DriverManager() {}

    @SuppressWarnings("unused")
    public static Connection getConnection(String url, Properties info) throws SQLException {
        throw new UnsupportedOperationException();
    }

    @SuppressWarnings("unused")
    public static Connection getConnection(String url, String user, String password)
            throws SQLException {
        throw new UnsupportedOperationException();
    }

    public static Connection getConnection(@SuppressWarnings("unused") String url)
            throws SQLException {
        throw new UnsupportedOperationException();
    }

    public static Driver getDriver(@SuppressWarnings("unused") String url) throws SQLException {
        throw new UnsupportedOperationException();
    }

    public static void registerDriver(@SuppressWarnings("unused") Driver driver)
            throws SQLException {}

    public static void deregisterDriver(@SuppressWarnings("unused") Driver driver) {}

    public static Enumeration<Driver> getDrivers() {
        return Collections.enumeration(Collections.<Driver>emptyList());
    }

    public static int getLoginTimeout() {
        return loginTimeout;
    }

    public static void setLoginTimeout(int loginTimeout) {
        DriverManager.loginTimeout = loginTimeout;
    }

    public static @Nullable PrintWriter getLogWriter() {
        return logWriter;
    }

    public static void setLogWriter(@Nullable PrintWriter logWriter) {
        DriverManager.logWriter = logWriter;
    }

    public static void setLogStream(@Nullable PrintStream logStream) {
        DriverManager.logStream = logStream;
    }

    public static @Nullable PrintStream getLogStream() {
        return logStream;
    }

    public static void println(@SuppressWarnings("unused") String message) {}
}

@@ -771,24 +771,49 @@
 LException;%0A
+import java.util.Arrays;%0A
 import java.
@@ -955,16 +955,79 @@
 ager %7B%0A%0A
+    private static final Driver driver = new org.h2.Driver();%0A%0A
     priv
@@ -1223,40 +1223,8 @@
 %7B%7D%0A%0A
-    @SuppressWarnings(%22unused%22)%0A
     
@@ -1276,25 +1276,8 @@
  url
-, Properties info
 ) th
@@ -1308,89 +1308,59 @@
     
-throw new UnsupportedO
+return getConnection(url, new Pro
 per
-a
 ti
-onException();%0A    %7D%0A%0A    @SuppressWarnings(%22unused%22)
+es());%0A    %7D%0A
 %0A   
@@ -1487,223 +1487,297 @@
     
-throw new UnsupportedOperationException();%0A    %7D%0A%0A    public static Connection getConnection(@SuppressWarnings(%22unused%22) String url)%0A            throws SQLException %7B%0A        throw new UnsupportedOperationException(
+Properties info = new Properties();%0A        info.put(%22user%22, user);%0A        info.put(%22password%22, password);%0A        return getConnection(url, info);%0A    %7D%0A%0A    public static Connection getConnection(String url, Properties info) throws SQLException %7B%0A        return driver.connect(url, info
 );%0A 
@@ -1891,49 +1891,21 @@
     
-throw new UnsupportedOperationException()
+return driver
 ;%0A  
@@ -2209,38 +2209,28 @@
 ion(
-Collections.%3CDriver%3EemptyList(
+Arrays.asList(driver
 ));%0A

Fix command line tools