传智博客ibatis 配置文件

  sqlMapConfig.xml


配置内容

 

 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"  

        "http://www.ibatis.com/dtd/sql-map-config-2.dtd">

<sqlMapConfig>

<transactionManager type="JDBC">

<dataSource type="SIMPLE">

<property name="JDBC.Driver" value="oracle.jdbc.OracleDriver" />

<property name="JDBC.ConnectionURL" value="jdbc:oracle:thin:@127.0.0.1:1521:oracle9i" />

<property name="JDBC.Username" value="itcast" />

<property name="JDBC.Password" value="itcast" />

</dataSource>

</transactionManager>

<sqlMap resource="com/itcast/Student.xml"></sqlMap>

</sqlMapConfig>


Student.xml

 

<?xml version="1.0" encoding="UTF-8" ?>


<!DOCTYPE sqlMap      

    PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"      

    "http://ibatis.apache.org/dtd/sql-map-2.dtd">

<sqlMap>

<typeAlias alias="Student" type="com.itcast.Student" />


<select id="selectAllStudent" resultClass="Student">

select * from student

</select>


<select id="selectStudentById" parameterClass="int" resultClass="Student">

select * from student where sid=#sid#

</select>


<insert id="insertStudent" parameterClass="student">

insert into

student(sid,sname,major,birth,score)

values(#sid#,#sname#,#major#,#birth#,#score#)

</insert>

<delete id="deleteStudentById" parameterClass="int">

delete from

Student where sid=#Fid#

</delete>


<update id="updateStudentById" parameterClass="Student">

update Student set

sname=#sname#,

major=#major#,

score=#score#,

birth=#birth#

where sid=#sid#

</update>

<select id="selectStudentByName" parameterClass="String"

resultClass="Student">

select sid,sname,major,birth,score from Student

where sname

like '%$sname$%' 

</select>


<insert id="insertStudentBySequence" parameterClass="Student">

<selectKey resultClass="int" keyProperty="sid">

select

studentPKSequence.nextVal

from dual

</selectKey>

insert into Student(sid,sname,birth,major,score)values

(#sid#,#sname#,#birth#,#major#,#score#)

</insert>

</sqlMap>

 

 



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值