The database we are coding for isn't well suited for making quick changes while doing index or query optimization, so I trying to find a good way to swap out the data abstraction layer cleanly to use a different database backend.

 Does anyone have any good examples of easily swapping data access layers?

 Example:

ClassA instantiates a DBQuery class to execute queries.  I would like to replace DBQuery with a DB2Query class which talks to a different database type.  The queries themselves will be the same, it's just the underlying API for communicating with the DB that is different.

I considered using reflection to determine a class to use on the fly, but I really want the solution to be performant and elegant.