der());
                }
            } else {
                setConnectionProvider(new DefaultConnectionProvider());
            }
        }
    }

    /**
     * Attempts to create a connection to the database and execute a query.
     *
     * @param errors A map populated with errors if they occur.
     * @return true if the test was successful, otherwise false.
     */
    public static boolean testConnection( Map<String,String> errors ) {
        boolean success = true;
        try ( final Connection con = DbConnectionManager.getConnection() )
        {
            // See if the Jive db schema is installed.
            try
            {
                Statement stmt = con.createStatement();
                // Pick an arbitrary table to see if it's there.
                stmt.executeQuery( "SELECT * FROM ofID" );
                stmt.close();
            }
            catch ( SQLException sqle )
            {
                success = false;
                Log.error( "The Openfire database schema does not appear to be installed.", sqle );
                errors.put( "general", "The Openfire database schema does not "
                    + "appear to be installed. Follow the installation guide to "
                    + "fix this error." );
            }
        }
        catch ( SQLException exception )
        {
            success = false;
            Log.error( "Unable to connect to the database.", exception );
            errors.put( "general", "A connection to the database could not be "
                + "made. View the error message by opening the "
                + "\"" + File.separator + "logs" + File.separator + "error.log\" log "
                + "file, then go back to fix the problem." );
        }
        return success;
    }

    /**
     * Returns a database connection from the currently active connection
     * provider. An exception will be thrown if no connection was found.
     * (auto commit is set to true).
     *
     * @return a connection.
     * @throws SQLException if a SQL ex