⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shopadresstreat.java

📁 是一个企业的进销存系统。账号问1001密码为123456
💻 JAVA
字号:
package com.jxc.dao;

	import java.sql.Connection;
	import java.sql.PreparedStatement;
	import java.sql.ResultSet;
	import java.sql.SQLException;
	import java.util.ArrayList;

	import com.jxc.dao.Dao;
    import com.jxc.vo.ShopAdress;
import com.jxc.vo.Vo;

	public class ShopAdressTreat implements Dao {

		public boolean deleteById(Connection conn, String id) {
			boolean flat=false;
			PreparedStatement pstm=null;
			int rs=0;
			String sql="delete from shopadress where gid=?";
			try {
				pstm=conn.prepareStatement(sql);
				pstm.setString(1, id);
				rs=pstm.executeUpdate();
				if(rs!=0)
					flat=true;
				else 
					flat=false;
				
			} catch (SQLException e) {
				e.printStackTrace();
			}finally{
				try {
					if(pstm!=null)
						pstm.close();
					if(conn!=null)
						conn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			
			return flat;
		}

		public boolean insert(Connection conn, Vo vo) {
			boolean flat=false;
			ShopAdress shopAdress=(ShopAdress)vo;
			PreparedStatement pstm=null;
			int rs=0;
			String sql="insert into shopadress(gid,gpho,gfac,gname)values(?,?,?,?)";
			try {
				pstm=conn.prepareStatement(sql);
				pstm.setString(1, shopAdress.getGid());
				pstm.setString(2, shopAdress.getGpho());
				pstm.setString(3, shopAdress.getGfac());
				pstm.setString(4, shopAdress.getGname());
				rs=pstm.executeUpdate();
				if(rs!=0)
					flat=true;
				else 
					flat=false;
			} catch (SQLException e) {
				e.printStackTrace();
			}finally{
				try {
					if(pstm!=null)
						pstm.close();
					if(conn!=null)
						conn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			return flat;
		}

		public ArrayList<ShopAdress> selectAll(Connection conn) {
			ArrayList<ShopAdress> arr=new ArrayList<ShopAdress>();
			PreparedStatement pstm=null;
			ResultSet rs=null;
			String sql="select gid,gpho,gfac,gname from shopadress";
			try {
				pstm=conn.prepareStatement(sql);
				rs=pstm.executeQuery();
				while(rs.next()){
					ShopAdress shopadress=new ShopAdress();
					shopadress.setGid(rs.getString(1));
					shopadress.setGpho(rs.getString(2));
					shopadress.setGfac(rs.getString(3));
					shopadress.setGname(rs.getString(4));
					arr.add(shopadress);
				}
			} catch (SQLException e) {
				
				e.printStackTrace();
			}finally{
				try {
					if(rs!=null)
						rs.close();
					if(pstm!=null)
						pstm.close();
					if(conn!=null)
						conn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			
			return arr;
		}

		public Vo selectById(Connection conn, String id) {
			ShopAdress vo=new ShopAdress();
			PreparedStatement pstm=null;
		    ResultSet rs=null;
		    String sql="select gid,gpho,gfac,gname from shopadress where gid=?";
		    try {
				pstm=conn.prepareStatement(sql);
				pstm.setString(1, id);
				rs=pstm.executeQuery();
				if(rs.next()){
				vo.setGid(rs.getString(1));
				vo.setGpho(rs.getString(2));
				vo.setGfac(rs.getString(3));
				vo.setGname(rs.getString (4));
				}	
		    } catch (SQLException e) {
				e.printStackTrace();
			}finally{
				try {
					if(rs!=null)
						rs.close();
					if(pstm!=null)
						pstm.close();
					if(conn!=null)
						conn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		    
			
			return vo;
		}

		public boolean updateById(Connection conn, String id, Vo vo) {
			boolean falt=false;
			ShopAdress shopadress=(ShopAdress)vo;
			PreparedStatement pstm=null;
			int rs=0;
			String sql="update shopadress set gid=?,gpho=?,gfac=?,gname=? where gid=?";
			try {
				pstm=conn.prepareStatement(sql);
				pstm.setString(1,shopadress.getGid());
				pstm.setString (2,shopadress.getGpho());
				pstm.setString(3, shopadress.getGfac());
				pstm.setString(4, shopadress.getGname());
				pstm.setString(5, id);
				rs=pstm.executeUpdate();
				if(rs!=0)
					falt=true;
				else
					falt=false;
				
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}finally{
				try {
					if(pstm!=null)
						pstm.close();
					if(conn!=null)
						conn.close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		    
			
			return falt;
			
		}


		public boolean selectId(Connection conn, String id) {
		
		boolean flat=false;
		PreparedStatement pstm=null;
	    ResultSet rs=null;
	    String sql="select * from shopadress where gid=?";
	    try {
			pstm=conn.prepareStatement(sql);
			pstm.setString(1, id);
			rs=pstm.executeQuery();
			if(rs.next()){
			flat=true;
			}else{
			flat=false;	
			}
	    } catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				if(rs!=null)
					rs.close();
				if(pstm!=null)
					pstm.close();
				if(conn!=null)
					conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	    
		
		return flat;
	}

	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -