示例#1
0
  public Member selectOne(int no) throws Exception {
    Connection con = null;
    PreparedStatement stmt = null;
    ResultSet rs = null;

    try {
      con = dataSource.getConnection();
      stmt = con.prepareStatement("select * from MEMBERS where MNO=?");
      stmt.setInt(1, no);
      rs = stmt.executeQuery();

      if (rs.next()) {
        Member member = new Member();
        member.setNo(rs.getInt("MNO"));
        member.setName(rs.getString("MNAME"));
        member.setEmail(rs.getString("EMAIL"));
        member.setPassword(rs.getString("PWD"));
        member.setTel(rs.getString("TEL"));
        return member;
      }

      return null;

    } finally {
      try {
        rs.close();
      } catch (Exception e) {
      }
      try {
        stmt.close();
      } catch (Exception e) {
      }
      dataSource.returnConnection(con);
    }
  }
示例#2
0
  public int delete(int no) throws Exception {
    Connection con = null;
    PreparedStatement stmt = null;

    try {
      con = dataSource.getConnection();
      stmt = con.prepareStatement("delete from MEMBERS where MNO=?");
      stmt.setInt(1, no);
      return stmt.executeUpdate();

    } finally {
      try {
        stmt.close();
      } catch (Exception e) {
      }
      dataSource.returnConnection(con);
    }
  }
示例#3
0
  public int insert(Member member) throws Exception {
    Connection con = null;
    PreparedStatement stmt = null;

    try {
      con = dataSource.getConnection();
      stmt = con.prepareStatement("insert into MEMBERS(MNAME,EMAIL,PWD,TEL)" + " values(?,?,?,?)");

      stmt.setString(1, member.getName());
      stmt.setString(2, member.getEmail());
      stmt.setString(3, member.getPassword());
      stmt.setString(4, member.getTel());

      return stmt.executeUpdate();

    } finally {
      try {
        stmt.close();
      } catch (Exception e) {
      }
      dataSource.returnConnection(con);
    }
  }
示例#4
0
  public List<Member> selectList() throws Exception {
    ArrayList<Member> list = new ArrayList<>();

    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;

    try {
      con = dataSource.getConnection();
      stmt = con.createStatement();
      rs = stmt.executeQuery("select * from MEMBERS");
      Member member = null;

      while (rs.next()) {
        member = new Member();
        member.setNo(rs.getInt("MNO"));
        member.setName(rs.getString("MNAME"));
        member.setEmail(rs.getString("EMAIL"));
        member.setPassword(rs.getString("PWD"));
        member.setTel(rs.getString("TEL"));
        list.add(member);
      }
      return list;

    } finally {
      try {
        rs.close();
      } catch (Exception e) {
      }
      try {
        stmt.close();
      } catch (Exception e) {
      }
      dataSource.returnConnection(con);
    }
  }
示例#5
0
  public int update(Member member) throws Exception {
    Connection con = null;
    PreparedStatement stmt = null;

    try {
      con = dataSource.getConnection();
      stmt = con.prepareStatement("update MEMBERS set MNAME=?, EMAIL=?, PWD=?, TEL=? where MNO=?");

      stmt.setString(1, member.getName());
      stmt.setString(2, member.getEmail());
      stmt.setString(3, member.getPassword());
      stmt.setString(4, member.getTel());
      stmt.setInt(5, member.getNo());

      return stmt.executeUpdate();

    } finally {
      try {
        stmt.close();
      } catch (Exception e) {
      }
      dataSource.returnConnection(con);
    }
  }