SSM框架封装好了Page以及PageData类
MySQL和Oracle项目中有以下几点不同:
1.dbconfig.properties的数据库配置
(1)MySQL的配置
url=jdbc:mysql://localhost:3306/ltc?useUnicode=true&characterEncoding=utf8
username=root
password=
driverClassName:com.mysql.jdbc.Driver
(2)Oracle的配置
url=jdbc:oracle:thin:@localhost:1521:DZDT
username=root
password=
driverClassName:oracle.jdbc.driver.OracleDriver
2.mybatis-config.xml里的配置(配置语言的分页语句)
(1)MySQL的配置
<property name="dialect" value="mysql"/>
(2)Oracle的配置
<property name="dialect" value="oracle/>
3.前端页面的EL表达式
(1)MySQL的配置(数据库默认值小写)
<option value="${type.ty_id}">${type.type_name}</option>
(2)Oracle的配置(数据库默认值大写)
<option value="${type.TY_ID}">${type.TYPE_NAME}</option>
4.数据库时间类型不一样,mybatis插入函数不一样
(1)MySQL的配置(数据库字段类型datetime,date_format和str_to_date函数)
date_format(#{createtime,jdbcType=VARCHAR},'%Y-%m-%d %h:%i:%s'),
(2)Oracle的配置(数据库字段类型date,to_date和to_char函数)
to_date(#{createtime,jdbcType=VARCHAR},'yyyy-mm-dd hh24:mi:ss'),
5.数据库mybatis执行多条语句不一样
(1)MySQL的配置(url基础配置加上允许多条一起执行)
url=jdbc:mysql://localhost:3306/ltc?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true
<delete id="delete" parameterType="pd">
delete from base_type
where ty_id = #{ty_id,jdbcType=VARCHAR};
delete from base
where typeid = #{ty_id,jdbcType=VARCHAR};
</delete>
(2)Oracle的配置(无需配置文件另外改,SQL语句加上BEGIN END;包裹即可,注意分号不能省略)
<delete id="delete" parameterType="pd">
BEGIN
delete from base_type
where ty_id = #{ty_id,jdbcType=VARCHAR};
delete from base
where typeid = #{ty_id,jdbcType=VARCHAR};
delete from T_TFWX_BASE where type_two in
(select T_ID from T_TFWX_TYPE_TWO where O_ID = #{typeId,jdbcType=VARCHAR});
END;
</delete>
6.数据库mybatis模糊查询不一样
(1)MySQL的配置
select <include refid="showAll"/>,t.ty_id,t.type_name,t.mark
from base s left join base_type t on s.typeid = t.ty_id
<where>
<if test="1 == 1">
1=1
</if>
<if test="pd.text != null and pd.text != ''">
AND s.title LIKE '%' #{pd.text} '%'
</if>
<if test="pd.begin != null and pd.begin != ''">
AND s.createtime > date_format(#{pd.begin},'%Y-%m-%d')
</if>
<if test="pd.end != null and pd.end != ''">
AND s.createtime < date_format(#{pd.end},'%Y-%m-%d')
</if>
<if test="pd.selectState != null and pd.selectState != '' and pd.selectState != -1">
AND s.typeid = #{pd.selectState}
</if>
<if test="1 == 1">
AND s.typeid != '-1'
</if>
</where>
ORDER BY s.createtime
(2)Oracle的配置
AND s.title LIKE '%' || #{pd.text} || '%'
AND s.createtime > to_date(#{pd.begin},'yyyy-mm-dd')
AND s.createtime < to_date(#{pd.end},'yyyy-mm-dd')