yashpal bharadwaj yashpal bharadwaj - 8 months ago 28
SQL Question

How can I change the currently used Database just by changing the configurations in Struts2

I have developed an application in Struts2 using MySQL at backend. But now as per interest I want to use Oracle at the back end.

For that I changed the db configurations to Oracle but I found that some of the MySQL queries are unable to run on Oracle directly.

I have searched too much and tried a few thing but still have no solution. Can anyone help here?


You can use Hibernate, it has dialects for both MySQL and Oracle. But if you use native queries then you should use separate code for each dialect.

In the BaseHibernateDAO you can create a method

protected Dialect getDialect(){
  return ((SessionFactoryImplementor) sessionFactory).getDialect();

Then you can use this dialect for any query you create.