【问题标题】:Changing Database from mysql to oracle using Hibernate使用 Hibernate 将数据库从 mysql 更改为 oracle
【发布时间】:2013-02-10 11:33:55
【问题描述】:

您好,我有一个小型 java 项目,正在使用 hibernate。现在我想将数据库更改为 oracle,我必须在配置文件中进行哪些更改才能使其成为可能。

【问题讨论】:

  • 只需更改数据源详细信息。

标签: java mysql oracle hibernate


【解决方案1】:

修改这些属性。在hibernate.cfg.xml中

<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
            <property name="hibernate.connection.password">your_new_password</property>
            <property name="hibernate.connection.url">jdbc:oracle:thin:@loalhost:xe</property>
            <property name="hibernate.connection.username">user_name</property>
            <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>

【讨论】:

    【解决方案2】:

    在您的 hibernate.cfg.xml 中,您应该定义了一个方言。该行如下所示:

     <property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
    

    改成这样:

    <property name="dialect">org.hibernate.dialect.OracleDialect</property>
    

    同时更改同一文件中的数据库连接参数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-03
      • 2018-08-05
      • 1970-01-01
      • 1970-01-01
      • 2015-01-27
      • 1970-01-01
      • 2021-10-01
      • 2012-02-12
      相关资源
      最近更新 更多