zoukankan      html  css  js  c++  java
  • 银行营业网点管理系统——implt包(CityAreaDaoImpl )

    package BranchesMgr.dao.impl;
    /**
     * 城区的实现类
     */
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.ArrayList;
    import java.util.List;
    
    import BranchesMgr.dao.BaseDao;
    import BranchesMgr.dao.CityAreaDao;
    import BranchesMgr.entity.CityArea;
    
    public class CityAreaDaoImpl extends BaseDao implements CityAreaDao {
    
    	@Override
    	//查询所有的城区
    	public List<CityArea> getCityArea() {
    		String sql="select * from CityArea";
    		List<CityArea>clist=new ArrayList<CityArea>();
    		try {
    			ResultSet rs=excuteQurey(sql, null);
    			while(rs.next()){
    				CityArea city=new CityArea();
    				city.setId(rs.getInt("id"));
    				city.setName(rs.getString("name"));
    				clist.add(city);
    			}
    		} catch (SQLException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}finally{
    			closeAll();
    		}
    		return clist;
    	}
    
    	@Override
    	//根据id查询城区信息
    	public CityArea cityById(int id) {
    		CityArea city=null;
    		List<Object> prams=new ArrayList<Object>();
    		String sql=null;
    		if(id==0){
    		 sql="select * from CityArea";
    		}else{
    			 sql="select * from CityArea where id=?";
    		}
    		prams.add(id);
    		try {
    			ResultSet rs=excuteQurey(sql, prams);
    			if(rs.next()){
    				 city=new CityArea();
    				city.setId(rs.getInt("id"));
    				city.setName(rs.getString("name"));
    			}
    		} catch (SQLException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}finally{
    			closeAll();
    		}
    		return city;
    	}
    
    }
    

  • 相关阅读:
    面试题:能谈谈Date、Datetime、Time、Timestamp、year的区别吗?
    面试题:对NotNull字段插入Null值 有啥现象?
    聊聊什么是慢查、如何监控?如何排查?
    谈谈MySQL的基数统计
    .vimrc
    HISKrrr的板子库
    CSP 模拟35
    晚测1
    CSP 模拟34
    nim板子题异或正确性YY
  • 原文地址:https://www.cnblogs.com/a1111/p/6540279.html
Copyright © 2011-2022 走看看