CentOS5.3上Oracle11g平台迁移(四)

2009年09月28日 CentOS/RedHat, Linux 暂无评论

验证一下数据到底成功迁移了没有

用putty连接

CentOS5.3上Oracle11g平台迁移(四)

OK,数据真的已经迁移了。

最后就是项目如何连接oracle

applicationContext.xml 改动连接参数,注意oracle的jdbcUrl写法

<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass"
value="oracle.jdbc.OracleDriver" />
<property name="jdbcUrl"
value="jdbc:oracle:thin:@//192.168.52.128:1521/fantlam" />
<property name="user" value="dbo_fantlam" />
<property name="password" value="dbo_fantlam" />
<property name="maxPoolSize" value="100" />
<property name="minPoolSize" value="1" />
<property name="initialPoolSize" value="1" />
<property name="maxIdleTime" value="5" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.OracleDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>oracle/vo/Note.hbm.xml</value>
</list>
</property>
</bean>

Note.hbm.xml 这里需要加多一个序列,也就是刚刚我们提到的note_id_SEQ

<hibernate-mapping>
<class name="oracle.vo.Note" table="NOTE">
<id name="id" type="java.lang.Long">
<column name="ID" precision="22" scale="0" />
<generator class="sequence">
<param name="sequence">note_id_SEQ</param>
</generator>

</id>
<property name="title" type="java.lang.String">
<column name="TITLE" length="20" not-null="true" />
</property>
<property name="author" type="java.lang.String">
<column name="AUTHOR" length="20" not-null="true" />
</property>
<property name="content" type="java.lang.String">
<column name="CONTENT" length="50" not-null="true" />
</property>
</class>
</hibernate-mapping>

OK,工作完成。

这里只是迁移一个小的程序,而且数据库比较简单,至于比较复杂的还待以后慢慢研究,比如触发器那些东西,不够迁移一个小数据量的程序应该还是没问题的。

至于在linux装weblogic也不用说了,跟win上一样。

给我留言