package com.shop.model;

import java.sql.*;

import javax.sql.*;
import javax.naming.*;

public class joinDAO {
 public Connection dbCon(){
  //Tomcat Context로 부터 jdbc/oracle이름의 DataSource를 가져와서
  //DB Connection객체를 생성해서 리턴
  //이 작업을 반복해서 하지 않도록 메서드로 작성.
  Connection con = null;
  try{
   Context ctx = new InitialContext();
   Context tomcat = (Context)ctx.lookup("java:comp/env");
   DataSource ds = (DataSource)tomcat.lookup("jdbc/oracle");
   con = ds.getConnection(); 
  }catch(Exception e){
   e.printStackTrace();
  }
  return con;
 }//dbCon end
 
 public void dbClose(Connection con, Statement stat, ResultSet rs){
  try{
   if(con!=null) con.close();
   if(stat!=null) stat.close();
   if(rs!=null) rs.close();
  }catch(Exception e){
   e.printStackTrace();   
  }
 }//dbClose end
 
 public boolean dupIdCheck(String uid){ //중복 ID체크 수행 메서드
  boolean success = false;
  Connection con = null;
  PreparedStatement stat = null;
  ResultSet rs = null;
  String sql = "select * from userinfo where userid = ? ";
  try{
   con = dbCon();
   stat = con.prepareStatement(sql);
   stat.setString(1, uid);
   rs = stat.executeQuery();
   while(rs.next()){
    if(rs.getString("userid").length() > 0) success = true;   
   }//while end
  }catch(Exception e){
   e.printStackTrace();   
  }finally{
   dbClose(con,stat,rs);
  }
  return success;
 }//dupIdCheck() end
 
 public UserVo joinProc(UserVo user){ //회원가입 처리 메서드
  UserVo vo = null;
  return vo;
 }//joinProc() end
}

'2020년도 이전 > temp' 카테고리의 다른 글

안드로이드 8월 13일 xml  (0) 2013.08.13
joinProcessServlet.java  (0) 2013.08.01
join_confirm --- 수정중!!  (0) 2013.07.31
서블릿 -- LoginServlet.java  (0) 2013.07.31
회원가입 디비 연결하자~~~ LoginDAO  (0) 2013.07.31

+ Recent posts