You need to provide a cfg.xml for each database.
Oracle.cfg.xml
mssql.cfg.xml
There you provide the appropriate database connecton configuration, the dialect to use and which hbm
-mapping files for the entity classes are needed
Within your code you create a single SessionFactory for each database.
SessionFactory oracleSF = Configuration.configure("oracle.cfg.xml").buildSessionFfactory();
SessionFactory msSF = Conf..configure("mssql.cfg.xml").build....
To reuse your util class you just have to pass the name of the config file to the method which creates the SessionFactory as an additional parameter.
The entity classes of the different tables are declared within the appropriate config file and therefore assigned to the right database, so hibernate knows which database to use.
Also take a look at this discussion which is about multiple schemas with a single cfg:
how to use Hibernate for two different schemas in a single database
Have a look here: It is a pretty nice site with an vast amount of tutorials for hibernate: