Jfinal框架目前处于比较火热的使用中,针对jfinal如何调用存储过程,在我之前开发的项目中,我是如下使用的,亲测有效!
public String getPartyMonthStatistics(String param) {
final Map<String, Object> map = new HashMap<String, Object>();
JSONObject jo = JSONObject.fromObject(param);
String domain = jo.getString("domain");
final String member_id = jo.getString("member_id");
Db.use(domain+"_r").execute(new ICallback() {
@Override
public Object call(Connection conn) throws SQLException {
CallableStatement proc = null;
try {
proc = conn.prepareCall("{call partymonthstatistics(?,?,?,?,?)}");
proc.setString(1, member_id);
proc.registerOutParameter(2, java.sql.Types.VARCHAR);
proc.registerOutParameter(3, java.sql.Types.VARCHAR);
proc.registerOutParameter(4, java.sql.Types.VARCHAR);
proc.registerOutParameter(5, java.sql.Types.VARCHAR);
proc.execute();
map.put("party_zch", proc.getString(2));
map.put("party_zdl", proc.getString(3));
map.put("party_xxjy", proc.getString(4));
map.put("party_yxl", proc.getString(5));
} catch (Exception e) {
e.printStackTrace();
}finally{
if(proc!=null){
proc.close();
}
if(conn!=null){
conn.close();
}
}
return null;
}
});
return JsonKit.toJson(map);
}
####Db的execute方法里还是调用了底层的Connection的prepareCall(“{call partymonthstatistics(?,?,?,?,?)}”),其中partymonthstatistics是数据库当中编写的存储过程名。
博客若对你有用,欢迎来我闲鱼平台逛逛,增加人气,闲鱼号“爱的魔力转圈圈”
空闲时间有空的话,给你提供一个解压平台,看看广告就能获取收益的APP。