コード例 #1
0
ファイル: MemberDao.java プロジェクト: eomjinyoung/Java80
  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);
    }
  }
コード例 #2
0
ファイル: MemberDao.java プロジェクト: eomjinyoung/Java80
  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);
    }
  }