By stubbing a database, you mean substituting database product Y for product X for testing purposes? If that's what you're looking at, most people tend to cater for such a need by placing the database connection properties in a configuration file and using the "test" version for tests, "prod" for production. If you're looking at avoiding accessing a database altogether in your tests, then you probably should look into mock objects. Also, my
book has a whole chapter dedicated to this stuff.