1. globals.propeties에 접속정보 추가
경로 : /src/main/reousrces/egovframework/egovProps/globals.properties
#ms-sql:DB
Globals.ms.DriverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
Globals.ms.Url=jdbc:sqlserver://127.0.0.1:1433;databaseName=디비명
Globals.ms.UserName=사용자
Globals.ms.Password=비밀번호
2. context-datasource.xml 에 추가
경로 : /src/main/reousrces/egovframework/spring/com/context-datasource.xml
<alias name="dataSource-ms" alias="ms.dataSource" />
<bean id="dataSource-ms" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${Globals.ms.DriverClassName}"/>
<property name="url" value="${Globals.ms.Url}" />
<property name="username" value="${Globals.ms.UserName}"/>
<property name="password" value="${Globals.ms.Password}"/>
<property name="initialSize" value="0"/>
<property name="maxActive" value="1"/>
<property name="maxIdle" value="1"/>
<property name="minIdle" value="0"/>
<property name="maxWait" value="-1"/>
</bean>
3. context-sqlMap.xml 에 추가
경로 : /src/main/reousrces/egovframework/spring/com/context-sqlMap.xml
<bean id="ms.sqlMapClient" class="egovframework.rte.psl.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocations">
<list>
<value>classpath:/egovframework/sqlmap/config/ms/*.xml</value>
</list>
</property>
<property name="dataSource" ref="dataSource-ms"/>
<property name="lobHandler" ref="lobHandler"/>
</bean>
4. sqlmap/config에 추가
경로 : /src/main/reousrces/egovframework/spring/sqlmap/config/ms/sql-map-config-ms.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/ms/SQL_Ms.xml"/>
</sqlMapConfig>
5. SQL_Ms.xml 생성
경로 : /src/main/reousrces/egovframework/spring/sqlmap/ms/SQL_Ms.xml
내용은 기존 방식과 동일
6. EgovAbstractDAO를 상속받는 DAO 클래스 생성
적절한 service 패키지 내에 생성한다.
public class EgovMssqlAbstractDAO extends EgovAbstractDAO {
@Override
@Resource(name = "ms.sqlMapClient")
public void setSuperSqlMapClient(SqlMapClient sqlMapClient) {
super.setSuperSqlMapClient(sqlMapClient);
}
}
7. DAO클래스 생성
import 서비스위치.EgovMssqlAbstractDAO;
@Repository("mssqlDAO")
public class MssqlDAO extends EgovMssqlAbstractDAO{
public List<?> selectUser(String uniqId){
return List<?> select("mssqlDAO.selectUser", uniqId);
}
}
8. ServiceImpl 설정
@Service("testService")
public class TestServiceImpl extends EgovAbstractServiceImpl implements TestService {
/** mssqlDAO */
@Resource(name="mssqlDAO")
private MssqlDAO mssqlDAO;
@Override
public List<?> selectUser(String uniqId) {
List<?> resultList = mssqlDAO.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' 카테고리의 다른 글
톰캣 ROOT로 배포하기 (0) | 2019.01.08 |
---|---|
전자정부프레임워크 DATABASE 오라클 복수 연결 설정 (0) | 2019.01.08 |
전자정부프레임워크 ibatis 프로시저 실행 (0) | 2019.01.08 |
[전자정부프레임워크] jave-2.0.jar ffmpeg 를 이용한 wav to mp3 변환 (0) | 2019.01.08 |
OSX 전자정부프레임워크 ojdbc 12.1 maven 수동설치 (0) | 2018.06.11 |