Friday, January 31, 2014

Hibernate Project&DB Connect with Orcl&Mysql and Covert DB 1 into another Format

Info: For eclipse tools jdk install not need but net been tools need jdk

**/ Hibernate Project ? 1. xml base and  2.annotation base

Oracle Library Need Jar : ojdbc14.jar
Mysql Library Need Jar : mysql-connector-java-5.1.12-bin.jar

WebContent/WEB-INF/classes/hibernate.cfg.xml configure 4 orcl
<hibernate-configuration >
    <session-factory>
        <property name="connection.useUnicode">true</property>
        <property name="connection.characterEncoding">UTF-8</property>

        <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
        <property name="connection.url">jdbc:oracle:thin:@192.168.0.246:1521:orcl</property>       
        <property name="connection.username">bfa</property>
        <property name="connection.password">bfa</property>
       
       
        <!-- oracle dialect -->
        <property name="dialect">org.hibernate.dialect.OracleDialect</property>
        <property name="current_session_context_class">thread</property>
        <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
        <property name="show_sql">true</property>   
        <property name="hbm2ddl.auto">update</property>
    </session-factory>
</hibernate-configuration>



WebContent/WEB-INF/classes/hibernate.cfg.xml configure 4 mysql
  <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/cid3</property>
    <property name="hibernate.connection.username">root</property>
  <property name="hibernate.connection.password">If its have password then write it HERE</property>
    <property name="hbm2ddl.auto">create</property>

                                                          Difference

   <property name="dialect">org.hibernate.dialect.OracleDialect</property>
   <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
   <property name="connection.url">jdbc:oracle:thin:@192.168.0.246:1521:orcl</property>
   <property name="connection.username">bfa</property>
   <property name="connection.password">bfa</property>




Learn How to open net been project and connect orcl database  
Now convert orcl database into mysql database.For this please at first mysql database create(blank database from php myadmin [wamp]) and  just connectivity change into mysql and project run then auto table create in mysql blank database

N.B (Mysql to orcl): If  I  want to do above instruction reverse situation then I have to type 1st time create then 2nd time type update , such as -
1st time : <property name="hbm2ddl.auto">create</property>
2nd time :<property name="hbm2ddl.auto">update</property> [ For  This situation above line no need ]


*/Learn How to open net been project and connect orcl database  Details

No comments:

Post a Comment