packagecom.springbook.biz.user.impl;importjava.sql.Connection;importjava.sql.PreparedStatement;importjava.sql.ResultSet;importcom.springbook.biz.common.JDBCUtill;importcom.springbook.biz.user.UserVO;// DAO(Data Access Object)/* UserDAO는 정상적인 bean 등록으로 객체생성할 예정이므로 어노테이션 설정 X
* BoardDAO에서는 @Repository를 사용했었음.
*/publicclassUserDAO{packagecom.springbook.biz.user.impl;importjava.sql.Connection;importjava.sql.PreparedStatement;importjava.sql.ResultSet;importorg.springframework.stereotype.Repository;importcom.springbook.biz.common.JDBCUtill;importcom.springbook.biz.user.UserVO;// DAO(Data Access Object)@Repository("userDAO")publicclassUserDAO{//JDBC 관련 변수privateConnectionconn=null;privatePreparedStatementstmt=null;privateResultSetrs=null;//SQL 명령어들privatefinalStringUSER_GET="select * from users where id=? and password=?";//CRUD 기능의 메소드 구현//회원 등록publicUserVOselectUser(UserVOvo){UserVOuser=null;try{System.out.println("===> JDBC로 getUser() 기능 처리");conn=JDBCUtill.getConnection();stmt=conn.prepareStatement(USER_GET);stmt.setString(1,vo.getId());stmt.setString(2,vo.getPassword());rs=stmt.executeQuery();if(rs.next()){user=newUserVO();user.setId(rs.getString("ID"));user.setPassword(rs.getString("PASSWORD"));user.setName(rs.getString("NAME"));user.setRole(rs.getString("ROLE"));}}catch(Exceptione){e.printStackTrace();}finally{JDBCUtill.close(rs,stmt,conn);}returnuser;}}
4. UserService 작성
1
2
3
4
5
6
7
8
9
packagecom.springbook.biz.user;publicinterfaceUserService{//CRUD 기능의 메소드 구현//회원 등록UserVOselectUser(UserVOvo);}
댓글남기기