1. globals.propeties에 접속정보 추가
경로 : /src/main/reousrces/egovframework/egovProps/globals.properties
#oracle DB2
Globals.DB2.DriverClassName=oracle.jdbc.driver.OracleDriver
Globals.DB2.Url=jdbc:oracle:thin:@127.0.0.1:1521:ORCL
Globals.DB2.UserName=아이디
Globals.DB2.Password=비밀번호
2. context-datasource.xml 에 추가
경로 : /src/main/reousrces/egovframework/spring/com/context-datasource.xml
<!-- Oracle DB2 -->
<bean id="dataSource-DB2" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${Globals.DB2.DriverClassName}"/>
<property name="url" value="${Globals.DB2.Url}" />
<property name="username" value="${Globals.DB2.UserName}"/>
<property name="password" value="${Globals.DB2.Password}"/>
<property name="initialSize" value="0"/>
<property name="maxActive" value="2"/>
<property name="maxIdle" value="2"/>
<property name="minIdle" value="0"/>
<property name="maxWait" value="-1"/>
</bean>
3. context-sqlMap.xml 에 추가
경로 : /src/main/reousrces/egovframework/spring/com/context-sqlMap.xml
<!-- SqlMap setup for iBATIS Database Layer -->
<bean id="DB2.sqlMapClient" class="egovframework.rte.psl.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocations">
<list>
<value>classpath:/egovframework/sqlmap/config/DB2/*.xml</value>
</list>
</property>
<property name="dataSource" ref="dataSource-DB2"/>
<property name="lobHandler" ref="lobHandler"/>
</bean>
4. sqlmap/config에 추가
경로 : /src/main/reousrces/egovframework/spring/sqlmap/config/DB2/sql-map-config-oracle-DB2.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<sqlMap resource="egovframework/sqlmap/DB2/DB2_SQL_Oracle.xml"/>
</sqlMapConfig>
5. DB2_SQL_Oracle.xml 생성
경로 : /src/main/reousrces/egovframework/spring/sqlmap/DB2/DB2_SQL_Oracle.xml
내용은 기존 방식과 동일
6. EgovAbstractDAO를 상속받는 abstract DAO 클래스 생성
적절한 service 패키지 내에 생성한다.
public abstract class EgovDBSecondAbstractDAO extends EgovAbstractDAO {
@Override
@Resource(name = "DB2.sqlMapClient")
public void setSuperSqlMapClient(SqlMapClient sqlMapClient) {
super.setSuperSqlMapClient(sqlMapClient);
}
}
7. DAO클래스 생성
import 서비스위치.EgovDBSecondAbstractDAO;
@Repository("dbSecondDAO")
public class DbSecondDAO extends EgovDBSecondAbstractDAO{
public List<?> selectUser(String uniqId){
return List<?> select("dbSecondDAO.selectUser", uniqId);
}
}
8. ServiceImpl 설정
@Service("testService")
public class TestServiceImpl extends EgovAbstractServiceImpl implements TestService {
/** dbSecondDAO */
@Resource(name="dbSecondDAO")
private DbSecondDAO dbSecondDAO;
@Override
public List<?> selectUser(String uniqId) {
List<?> resultList = dbSecondDAO.selectUser(uniqId);
return resultList;
}
}
9. 컨트롤러내 추가(기존 방식과 동일)
/** testService */
@Resource(name = "testService")
private TestService testService;
@RequestMapping(value = "/test/list.do", method=RequestMethod.GET)
public String selectUserList(@RequestParam(value = "uniqId", required = false) final String uniqId, ModelMap model) throws Exception {
model.addAttribute("resultList", resultList);
끝.
'JAVA' 카테고리의 다른 글
윈도우즈 톰캣 멀티포트 서비스 구성 (0) | 2019.01.08 |
---|---|
톰캣 ROOT로 배포하기 (0) | 2019.01.08 |
전자정부프레임워크 SQL Server (MSSQL) 연결 추가 (0) | 2019.01.08 |
전자정부프레임워크 ibatis 프로시저 실행 (0) | 2019.01.08 |
[전자정부프레임워크] jave-2.0.jar ffmpeg 를 이용한 wav to mp3 변환 (0) | 2019.01.08 |