Parsing DATABASE_URI, use URI#hostname: it's smarter about IPv6

Fixes #15705.

Conflicts:
	activerecord/lib/active_record/connection_adapters/connection_specification.rb
	activerecord/test/cases/connection_adapters/connection_handler_test.rb