Hi,
If you can let us know what is the requirement then it might be more helpful.
In case you need to connect to different databases because you are promoting your code through different development environments then that is easily achievable. While building the code for particular environment you can replace the DB using
ant scripts and build.properties file.
However if the requirement is like having multiple databases connections in a single environment then you will need different SessionFactories for each of the DB as mentioned by Paul earlier.
Regds,
Amit