您的位置:首页 > 数据库 > MySQL

hibernate 调用mysql存储过程

2013-10-28 17:19 405 查看
@Override
public String processData(final String taxPayerNo,final String period) throws Exception {

return (String)this.getHibernateTemplate().execute(new HibernateCallback() {

@Override
public Object doInHibernate(Session session) throws HibernateException,
SQLException {
Connection conn = session.connection();
CallableStatement pstmt = null;
String result = null;
try{
pstmt = conn.prepareCall("{ call creat_cal_report_data(?,?,?)}");
pstmt.setString(1, taxPayerNo);
pstmt.setString(2, period);
pstmt.registerOutParameter(3,java.sql.Types.VARCHAR);
pstmt.executeQuery();
result = (String) pstmt.getObject(3);

}catch(Exception e){
e.printStackTrace();
}

return result;
}
});
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: