Skip to content

Commit

Permalink
중복제거
Browse files Browse the repository at this point in the history
  • Loading branch information
kenu committed Dec 7, 2014
2 parents c39802e + ac24653 commit 128ad28
Showing 1 changed file with 16 additions and 37 deletions.
53 changes: 16 additions & 37 deletions src/main/java/kr/pe/okjsp/member/MemberHandler.java
Expand Up @@ -20,7 +20,7 @@
* @author kenu
*/
public class MemberHandler {
static Logger logger = LoggerFactory.getLogger(MemberHandler.class);
private static Logger LOGGER = LoggerFactory.getLogger(MemberHandler.class);

DbCon dbCon = new DbCon();

Expand Down Expand Up @@ -58,34 +58,8 @@ public class MemberHandler {
* @throws SQLException
*/
public boolean isIdExist(String id) throws SQLException {
boolean isExist = true;

if (id == null) return true;

Connection pconn = dbCon.getConnection();
PreparedStatement pstmt = null;
ResultSet rs = null;

try{
pstmt = pconn.prepareStatement(QUERY_EXISTS);
pstmt.setString(1,id);

rs = pstmt.executeQuery();
if(rs.next()) {
int cnt = rs.getInt(1);
if (cnt == 0) {
isExist = false;
}
}
rs.close();
pstmt.close();
}catch(Exception e){
logger.info("Member Handler isIdExist err:"+e.getMessage());
} finally {
dbCon.close(pconn, pstmt, rs);
}

return isExist;
return isExist(id, QUERY_EXISTS);
}


Expand All @@ -96,18 +70,22 @@ public boolean isIdExist(String id) throws SQLException {
* @throws SQLException
*/
public boolean isEmailExist(String email) throws SQLException {
// default true;
boolean isExist = true;

if (email==null) return true;
return isExist(email, QUERY_EMAIL_EXISTS);

}


private boolean isExist(String item, String queryExists)
throws SQLException {
boolean isExist = true;
Connection pconn = dbCon.getConnection();
PreparedStatement pstmt = null;
ResultSet rs = null;

try{
pstmt = pconn.prepareStatement(QUERY_EMAIL_EXISTS);
pstmt.setString(1,email);
pstmt = pconn.prepareStatement(queryExists);
pstmt.setString(1,item);

rs = pstmt.executeQuery();
if(rs.next()) {
Expand All @@ -119,14 +97,15 @@ public boolean isEmailExist(String email) throws SQLException {
rs.close();
pstmt.close();
}catch(Exception e){
logger.info("Member Handler isEmailExist err:"+e.getMessage());
LOGGER.info(e.getMessage());
} finally {
dbCon.close(pconn, pstmt, rs);
}

return isExist;
}


/**
* Method changeInfo
* @param member
Expand Down Expand Up @@ -397,7 +376,7 @@ public void profileLog(long sid) throws SQLException {

pstmt.close();
} catch(Exception e){
logger.info(e.toString());
LOGGER.info(e.toString());
} finally {
dbCon.close(pconn, pstmt);
}
Expand All @@ -424,7 +403,7 @@ public String reject(String email) throws SQLException {

pstmt.close();
} catch(Exception e){
logger.info(e.toString());
LOGGER.info(e.toString());
} finally {
dbCon.close(pconn, pstmt);
}
Expand Down Expand Up @@ -467,7 +446,7 @@ public boolean isMailing(String email) throws SQLException {
rs.close();
pstmt.close();
}catch(Exception e){
logger.info("Member Handler isEmailExist err:"+e);
LOGGER.info("Member Handler isEmailExist err:"+e);
} finally {
dbCon.close(pconn, pstmt, rs);
}
Expand Down

0 comments on commit 128ad28

Please sign in to comment.