从序列中读取自增长字段的方法:
1.       studemt.xml中加入如下代码:
<insert id=”insertStudentBySequence” parameterClass=”Student”>
        <!--读取序列,值保存到sid变量中-->
        <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>
 
2.       IStudentDAOImpl.java加入如下代码:
public void addStudentBySequence(Student student){
        try{
               // insertStudentBySequence是插入语句的id
       sqlMapClient.insert(“insertStudentBySequence”,student);
}catch(SQLException e){
       e.printStackTrace();
}
}