zoukankan      html  css  js  c++  java
  • oracle转mysql数据库 (hibernate+spring)

    用工具将oracle数据库变为mysql数据库的数据。然后自己修改,包括主键,视图,存储过程等。

    1.proxool.xml

    <driver-url>jdbc:mysql://10.7.5.206:3306/mydb</driver-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>

    2.spring 中sessionfactory配置

    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.proxool.pool_alias">proxooldatascr</prop>
    <prop key="hibernate.proxool.xml">proxool.xml</prop>
    <prop key="hibernate.connection.provider_class">
    org.hibernate.connection.ProxoolConnectionProvider
    </prop>
    <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.generate_statistics">false</prop>
    <prop key="hibernate.format_sql">true</prop>
    <prop key="current_session_context_class">thread</prop>
    </props>
    </property>

    <property name="mappingDirectoryLocations">
    <list>
    <value>classpath:com/tazi/domain/pojo</value>
    </list>
    </property>
    </bean>

    3.hbm配置文件中把sequence主键生成方式改为identitiy ,对应表的主键要改为interger,auto_increment ,primary key

    4.函数转化

    substr不变,max,min不变

    nvl函数转为ifnull函数

    to_char(m.mac_eventtime,'yyyy-MM-dd hh24:MI:ss')转化DATE_FORMAT(m.mac_eventtime,'%Y-%m-%d %H:%i:%s')

    进制转换 to_char(源字符串,)

    5.字段类型转化

    date转化为timestamp不然日期仅有年月日

    当前日期sysdate要根据需要使用curdate(),curtime(),now()等。

    6.select xx,XX from(

      select dd from ddd

    ) V   此处必须加别名

     7.解决 SELECT command denied to user 'XX'@'10.7.3.41' for table 'xxx'

    问题 ,查看hbm映射文件中有没有schema="xxx"之类,全部去掉。

  • 相关阅读:
    springmvc
    POJ 3683 Priest John's Busiest Day
    POJ 3678 Katu Puzzle
    HDU 1815 Building roads
    CDOJ UESTC 1220 The Battle of Guandu
    HDU 3715 Go Deeper
    HDU 3622 Bomb Game
    POJ 3207 Ikki's Story IV
    POJ 3648 Wedding
    HDU 1814 Peaceful Commission
  • 原文地址:https://www.cnblogs.com/tazi/p/2616509.html
Copyright © 2011-2022 走看看