Example #1
0
  @Override
  public Object processCommand(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    String dong = req.getParameter("dong");
    Vector v = new Vector();

    Connection con = null;
    PreparedStatement stmt = null;
    ResultSet rs = null;
    DBConnectionMgr pool = null;
    try {
      pool = DBConnectionMgr.getInstance();
      con = pool.getConnection();
      String sql = "select * from tblzip where dong like'%" + dong + "%'";
      stmt = con.prepareStatement(sql);
      rs = stmt.executeQuery();
      while (rs.next()) {
        ZipDto zip = new ZipDto();
        zip.setZipcode(rs.getString("zipcode"));
        zip.setSido(rs.getString("sido"));
        zip.setDong(rs.getString("dong"));
        zip.setGugun(rs.getString("gugun"));
        zip.setBunji(rs.getString("bunji"));

        v.add(zip);
      }
    } catch (Exception err) {
      System.out.println("zipCommand : " + err);
    } finally {
      pool.freeConnection(con, stmt, rs);
    }
    req.setAttribute("zip", v);
    return "/exam3/zipSearch.jsp";
  }
Example #2
0
 public sign_upMgr() {
   try {
     pool = DBConnectionMgr.getInstance();
   } catch (Exception e) {
     System.out.println("Error : Exception");
   }
 }
Example #3
0
  public boolean getResult() {
    Connection conn = null;
    Statement stmt = null;
    ResultSet rs = null;
    boolean flag = false;
    try {
      conn = pool.getConnection();

      String strQuery = "select * from usertable where Email = '" + param.getEmail() + "'";
      stmt = conn.createStatement();
      rs = stmt.executeQuery(strQuery);
      if (rs.next()) {
        System.out.println("Alreay Exist");
        flag = false;
        return flag;
      }
      System.out.println("AAA");
      // DB에 삽입할 쿼리문 생성
      strQuery =
          "insert into usertable (UserName,Email,PassWord) "
              + "VALUES('"
              + param.getUserName()
              + "', '"
              + param.getEmail()
              + "', '"
              + param.getPassWord()
              + "')";
      //
      System.out.println(strQuery);
      stmt = conn.createStatement();
      stmt.executeUpdate(strQuery);
      flag = true;
    } catch (Exception ex) {
      System.out.println("Exception" + ex);
    } finally {
      pool.freeConnection(conn);
    }
    return flag;
  }