use global type cache for database types

This changes to using an internal globalTypeCache to determine what
the current database type is, optimizing the lookups and allowing for a potential future where
multiple databases are used in the same process