存储过程定义:
DELIMITER $$
DROP procedure IF EXISTS pro_sql_data1 $$?
CREATE procedure pro_sql_data1(in sear_name? varchar(2000))?
BEGIN?
?if sear_name is not null and sear_name!='' then
? select id,name,date_format(create_time,'%Y-%m-%d') as repDate from ad_place where
? name like concat('%',sear_name,'%');
?ELSE
? select id,name,date_format(create_time,'%Y-%m-%d') as repDate from ad_place;
?end if;
?
END$$
DELIMITER;
执行结果:

在mybatis中调用存储过程,然后获取该结果集:
1、xml配置文件
?
?
? ? ?
? ? ?
? ? ?
? ? ?
? ?
? ?
??
Java代码
public String query(String param) throws Exception {
? logger.info(param);
? Map queryMap = new HashMap();
? queryMap.put("obj", param);
? //List
注:有上面可知,mysql存储过程中可以直接使用select语句返回结果集,而且mybatis可以直接使用list接收这个结果集(无需游标)。