I want to connect several databases, such as SQL and Oracle, with different databases. So I already had MSSQL hibernate.cfg.xml and the Hibernateutil class for the factory session. Now I am trying to connect to oracle with a different table.
Please advise that I can use the same cgf.xml, and the util class can also tune oracle databases.
This is where the class is used.
public class HibernateUtil {
private static final SessionFactory sessionFactory = buildSessionFactory();
@SuppressWarnings("deprecation")
private static SessionFactory buildSessionFactory()
{
try
{
SessionFactory sessionFactory = new Configuration().configure("/DAO/hibernate.cfg.xml").buildSessionFactory();
return sessionFactory;
}
catch (Throwable ex) {
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
public static void shutdown() {
getSessionFactory().close();
}
}
source
share