码迷,mamicode.com
首页 > 编程语言 > 详细

java 调用存储过程

时间:2016-03-17 12:51:46      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:

 1

1         String sql="{CALL P_F_CHECK6(?,?,?)}";
2         Object[] inValues = new Object[]{reportId, reportDate, organId};
3         int [] inIndexes = new int[]{1,2,3};
4         jdbcCall(sql, inValues, inIndexes);


2

1     protected Object jdbcCall(final String sql, final Object[] inValues,
2             int[] inIndexes) {
3          jdbcCall(sql, inValues, inIndexes,
4                 DEFAULT_LOB_SIZE);
5          return null;
6     }


3

 1     protected void jdbcCall(final String sql, final Object[] inValues,
 2              final int[] inIndexes,
 3              final int lobSize) {
 4         HibernateCallback callback = new HibernateCallback() {
 5             public Object doInHibernate(Session session)
 6                     throws HibernateException, SQLException {
 7                 CallableStatement cs = session.connection().prepareCall(sql);
 8                 setCallableStatementInParameters(cs, inValues, inIndexes);
 9                 registerCallableStatementOutParameter(cs, null, null);
10                 Object[] result = getCallableStatementOutParameter(cs, null,null, lobSize);
11                 cs.execute();
12                 cs.close();
13                 return result;
14             }
15         };
16          getHibernateTemplate().execute(callback);
17         
18     }

 

java 调用存储过程

标签:

原文地址:http://www.cnblogs.com/hehongtao/p/5286748.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!