xml內容示例:
<sql id="001" comment="查詢學生信息"></sql>
select * fom t_stu a
where a.stu_id='{0}'
and a.stu_name='{1}'
<sql id="002" comment="更新學生信息"></sql>
update t_stu a
set a.comment='學生{1}'||'學號:{0}'
where set a.stu_id='{0}'
java 僞代碼:
String sql = sqlUtil.getSQLByID("001");
String comment = sqlUtil.getCommentByID("001");
sql.setParamMeterByName(0,"100");
sql.setParamMeterByName(1,"張三");
這時sql字符串的內容實際爲:
sql = "select * fom t_stu a where a.stu_id='100' and a.stu_name='張三';
stmt.executesql(sql);
println(comment+"執行成功!");