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 | 31 |
Tags
- Sqoop
- xPlatform
- MSSQL
- Eclipse
- SPC
- Python
- plugin
- tomcat
- mybatis
- R
- hadoop
- table
- es6
- window
- Express
- NPM
- IntelliJ
- Android
- 공정능력
- SSL
- 보조정렬
- vaadin
- react
- JavaScript
- GIT
- Kotlin
- SQL
- Java
- mapreduce
- Spring
Archives
- Today
- Total
DBILITY
spring mybatis stored procedure ( oracle ) 본문
반응형
spring 3.1.1, mybatis 3.2.7, spring-mybatis 1.2.2, oracle 11g r2 환경하에서
spring task로 oracle stored procedure 실행 후 결과를 받는 실례 중 주요코드입니다.
- sched.java
@Scheduled(cron = "${cron.SCHED001_FILTER_INSERT}") public void cronSched001FilterInsert() throws Exception { service.execProcdure("SCHED001_FILTER_INSERT"); }
- service.java
@Async public void execProcdure(String procNm) throws Exception { HashMap<string,object> commandMap = new HashMap<string,object> (); commandMap.put("SCHED_ID", procNm); dao.execJobProcedure("com.dbility.sched.mapper."+procNm,commandMap) ; LOG.info("SCHED_LRU_MSG : {}", commandMap.get("result")); }
- dao.java
@Resource(name="sqlSessionTemplate") private SqlSessionTemplate sqlSession; public void execJobProcedure(String sqlId,HashMap<string,object> commandMap) throws SQLException { sqlSession.selectOne(sqlId,commandMap); }
- mapper.xml
parameterType은 생략 가능하며,mode=OUT설정된 parameter에 procedure 결과가 저장됩니다.
<select id="SCHED001_FILTER_INSERT" parameterType="java.util.HashMap" statementType="CALLABLE"> { call DBILITYDBA.SCHED001_FILTER_INSERT(#{v_date,mode=IN,jdbcType=VARCHAR},#{v_shift,mode=IN,jdbcType=VARCHAR},#{result,mode=OUT,jdbcType=VARCHAR})} </select>
- procedure.prc
CREATE OR REPLACE PROCEDURE DBILITYDBA.SCHED001_FILTER_INSERT(V_DATE IN VARCHAR2,V_SHIFT IN VARCHAR2,V_MSG OUT VARCHAR2) IS START_TIME NUMBER; END_TIME NUMBER; /****************************************************************************** NAME: SCHED001_FILTER_INSERT PURPOSE: 예제 REVISIONS: Ver Date Author Description --------- ---------- --------------- ------------------------------------ 1.0 2016/09/24 ROOKIE 1. Created this procedure. ******************************************************************************/ BEGIN START_TIME := DBMS_UTILITY.GET_TIME; /* SQL CODE */ END_TIME := DBMS_UTILITY.GET_TIME; V_MSG := 'SCHED001_FILTER_INSERT ELAPSED: '||TO_CHAR( (END_TIME-START_TIME)/100,'FM9,990.990')||' ,Rows affected : '||TO_CHAR(SQL%ROWCOUNT,'FM999,999,990')'; COMMIT; EXCEPTION WHEN NO_DATA_FOUND THEN NULL; WHEN OTHERS THEN ROLLBACK; --DBMS_OUTPUT.PUT_LINE('SCHED001_FILTER_INSERT ERROR: '||SQLERRM); V_MSG := 'SCHED001_FILTER_INSERT ERROR: '||SQLERRM; RAISE; END SCHED001_FILTER_INSERT; /
반응형
'java > spring' 카테고리의 다른 글
PropertyPlaceholder에 ARIA Crypto 적용하기 (0) | 2017.09.07 |
---|---|
spring bean programmatically register to web applicaton context (0) | 2016.10.24 |
logback에서 springframework log가 출력되지 않을때 (0) | 2016.10.21 |
java spring cron expression (0) | 2016.09.20 |
spring jta db,file transaction examination (0) | 2016.09.09 |
Comments