Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- Oracle
- 정보처리기사
- 오라클
- 라우터
- php
- Java
- jsp
- 참조타입
- sql
- 원형그래프
- 정처기필기
- ciscopacket
- 버추얼머신
- 자바
- jsp연결
- rinux
- NCS
- 네트워크
- 네트워크관리사
- cisco packet
- Cisco
- html
- VLAN
- ospf
- 데이터베이스
- 리눅스
- autoset
- w3school
- javaee
- 이것이 자바다
Archives
- Today
- Total
기록해! 정리해!
비즈니스 컴포넌트 실습 II ( 어노테이션으로 수정 ) 본문
[ applicationContext.xml ]
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<context:component-scan base-package="com.springbook.biz" />
</beans>
---------------------------------------------------------------------------------------------------------------------------
package com.springbook.biz.user.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.springbook.biz.user.UserDao;
import com.springbook.biz.user.UserService;
import com.springbook.biz.user.UserVo;
@Service("userService")
public class UserServiceImpl implements UserService {
@Autowired
private UserDao userDao;
@Override
public UserVo getUser(UserVo vo) {
// TODO Auto-generated method stub
return userDao.getUser(vo);
}
}
======================================================================
package com.springbook.biz.user.impl;
import java.sql.*;
import org.springframework.stereotype.Repository;
import com.springbook.biz.common.JDBCUtil;
import com.springbook.biz.user.UserDao;
import com.springbook.biz.user.UserVo;
@Repository
public class UserDaoImpl implements UserDao {
private JDBCUtil dbConn =null;
private Connection conn = null;
private PreparedStatement pstmt=null;
private ResultSet rs=null;
UserDaoImpl(){
dbConn=JDBCUtil.getInstance();
}
@Override
public UserVo getUser(UserVo vo) {
System.out.println(" ===> getUser(UserVo vo) 기능처리 " );
UserVo user = null;
try {
conn = dbConn.getConnection();
String SQL="select * from users where id=? and password=?";
pstmt=conn.prepareStatement(SQL);
pstmt.setString(1, vo.getId());
pstmt.setString(2, vo.getPassword());
rs=pstmt.executeQuery();
rs.next();
user=new UserVo();
user.setId(rs.getString("id"));
user.setName(rs.getString("name"));
user.setPassword(rs.getString("password"));
user.setRole(rs.getString("role"));
}catch(Exception e) {
e.printStackTrace();
}
return user;
}
}
'Spring' 카테고리의 다른 글
JoinPoint 메소드 사용하기 (0) | 2022.09.22 |
---|---|
AOP 사용하기 (0) | 2022.09.22 |
비즈니스 컴포넌트 실습 II (0) | 2022.09.22 |
카카오 API 지도 (2) - 데이터 연동 (0) | 2022.09.21 |
비즈니스 컴포넌트 실습 I (복습) - Board (1) | 2022.09.21 |
Comments