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+"执行成功!");