免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
生成報(bào)表Dao類
package com.sys.volunteer.reportview.services;
import java.util.List;
import java.util.Map;
import com.sys.volunteer.pagemodel.PageView;
/***
 *
 * @author dw
 *
 */
public interface ViewDao {
 
 //函數(shù)輸出參數(shù)名,分頁模塊數(shù)據(jù)總條數(shù)
 final static String TOTALRECORD_FLAG="totalrecord";
 
 //每頁顯示數(shù)量
 final static String PAGE_SIZE_FLAG="pageSize";
 
 //當(dāng)期頁
 final static String CURRENT_PAGE_FLAG="currentPage";
 /**
  * 返回存儲(chǔ)過程執(zhí)行結(jié)果
  *
  * @author dw
  * @param procedureQL
  *            存儲(chǔ)過程
  * @param params
  *            對(duì)應(yīng)參數(shù)
  * @return List
  */
 List getListByRepAndParams(String procedureQL, Object[] params);
 
 List getListByRepAndParams(String procedureQL, Map params);
 
 void getListByRepAndParams(String procedureQL, Map<String, Object> values, PageView pageView);
}

 
 
 
 
 
 
 
package com.sys.volunteer.reportview.services;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.sys.volunteer.pagemodel.PageView;
/***
 *
 * @author dw
 *
 */
@Service
@Transactional
public class ViewDaoImpl implements ViewDao {
 
 @Resource
 private HibernateTemplate hibernateTemplate;
 /**
  * 返回報(bào)表結(jié)果
  *
  * @author dw
  * @param procedureQL
  *            存儲(chǔ)過程
  * @param params
  *            對(duì)應(yīng)參數(shù)
  * @return List
  */
 public List getListByRepAndParams(String procedureQL, Object[] params) {
  List returnList = null;
  CallableStatement cstmt = null;
  ResultSet rs = null;
  Session session = hibernateTemplate.getSessionFactory().openSession();
  Connection con = (Connection) session.connection();
  try {
   cstmt = con.prepareCall(procedureQL);
   setCallParams(params, cstmt);
   rs = (ResultSet) cstmt.executeQuery();
   returnList = listRsToMap(rs);
   cstmt.close();
   rs.close();
   con.close();
  } catch (Exception e) {
   e.printStackTrace();
  } finally {
   session.close();
  }
  return returnList;
 }
 
 
 /**
  * 返回報(bào)表結(jié)果
  *
  * @author dw
  * @param procedureQL
  *            存儲(chǔ)過程
  * @param params
  *            對(duì)應(yīng)參數(shù)
  * @return List
  */
 public List getListByRepAndParams(String procedureQL, Map params) {
  List returnList = null;
  CallableStatement cstmt = null;
  ResultSet rs = null;
  Session session = hibernateTemplate.getSessionFactory().openSession();
  Connection con = (Connection) session.connection();
  try {
   cstmt = con.prepareCall(procedureQL);
   setCallParams(params, cstmt);
   rs = (ResultSet) cstmt.executeQuery();
   returnList = listRsToMap(rs);
   cstmt.close();
   rs.close();
   con.close();
  } catch (Exception e) {
   e.printStackTrace();
  } finally {
   session.close();
  }
  return returnList;
 }
 
 /**
  * 返回報(bào)表結(jié)果
  *
  * @author dw
  * @param procedureQL
  *            存儲(chǔ)過程
  * @param params
  *            對(duì)應(yīng)參數(shù)
  * @return List
  */
 public void getListByRepAndParams(String procedureQL, Map params,PageView pageView) {
  List returnList = null;
  CallableStatement cstmt = null;
  ResultSet rs = null;
  
  Session session = hibernateTemplate.getSessionFactory().openSession();
  Connection con = (Connection) session.connection();
  try {
   
   cstmt = con.prepareCall(procedureQL);
   
   setCallParams(params, cstmt);
   //輸出參數(shù),總條數(shù)
   cstmt.registerOutParameter(TOTALRECORD_FLAG, Types.INTEGER);
   
   rs = (ResultSet) cstmt.executeQuery();
   pageView.setTotalrecord(cstmt.getInt(PAGE_SIZE_FLAG));
   pageView.setTotalrecord(cstmt.getInt(CURRENT_PAGE_FLAG));
   pageView.setTotalrecord(cstmt.getInt(TOTALRECORD_FLAG));
   
   returnList = listRsToMap(rs);
   
   pageView.setRecords(returnList);
   
   cstmt.close();
   rs.close();
   con.close();
   
  } catch (Exception e) {
   e.printStackTrace();
  } finally {
   session.close();
  }
 }
 
 /**
  * 返回列名小寫的Map集合
  *
  * @author dw
  * @param rs
  * @return List
  * @throws Exception
  */
 private List listRsToMap(ResultSet rs) throws Exception {
  List<Map<String, Object>> rslist = new ArrayList<Map<String, Object>>();
  Map<String, Object> map = null;
  ResultSetMetaData rsmd = rs.getMetaData();
  int col_count = rsmd.getColumnCount();
  while (rs.next()) {
   map = new HashMap<String, Object>();
   for (int i = 1; i <= col_count; i++) {
    map.put(rsmd.getColumnName(i).toLowerCase(), rs.getObject(i));
   }
   rslist.add(map);
  }
  return rslist;
 }
 /**
  * @author dw
  * @param params
  * @param cstmt
  * @throws SQLException
  */
 private void setCallParams(Object[] params, CallableStatement cstmt)
   throws SQLException {
  if (params != null && params.length > 0) {
   for (int i = 0; i < params.length; i++) {
    cstmt.setObject(i+1, params[i]);
   }
  }
 }
 
 /**
  * @author dw
  * @param params
  * @param cstmt
  * @throws SQLException
  */
 private void setCallParams(Map params, CallableStatement cstmt)
   throws SQLException {
  
  if (params != null && !params.isEmpty()) {
   Set set = params.keySet();
   Iterator it = set.iterator();
   while (it.hasNext()) {
    String key = it.next().toString();
    cstmt.setObject(key,params.get(key));
   }
  }
 }
}

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Java 中調(diào)用oracle 的過程
java調(diào)用存儲(chǔ)過程無法取得返回參數(shù)
java oracle bulk insert
Spring:JdbcTemplate使用指南
BaseDao
使用Spring 中RowMapper
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服