2016년 12월 18일 일요일

[java] 프로시저 호출하기

코드 예)


DBConnectionPool connPool = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
CallableStatement cstmt = null;

.
.
.
.


클래스 상단 전역 변수로 선언되어있는 데이터베이스 관련 객채들.
코드상엔 없지만 connPool  커넥션풀에 데이터베이스 커넥션 싱글톤 처리가 되었다고 가정한다.

try{  
        //쿼리  
String sql = "{ CALL PROC_COMMENT_INSERT( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) }";

        //커넥션을 얻는다.
conn = connPool.getConnection();
        //스테이트먼트 객체를 얻는다
cstmt = conn.prepareCall(sql);
        //전달 파타미터 셋팅
cstmt.setLong(1, ac_article_seq);
cstmt.setLong(2,(long)0);
cstmt.setLong(3, mb_seq);
cstmt.setString(4,mn_nickname);
cstmt.setInt(5,Integer.parseInt((String)member.get("MB_LEVEL")));
cstmt.setString(6,"U");
cstmt.setString(7,comment);
cstmt.setString(8,(String)member.get("MB_LAST_LOGIN_IP"));
//전달 파라미터 셋팅끝

        //프로시저 리턴 파라미터
cstmt.registerOutParameter(9, java.sql.Types.BIGINT);
cstmt.registerOutParameter(10, java.sql.Types.SMALLINT);
cstmt.registerOutParameter(11, java.sql.Types.TINYINT);
cstmt.registerOutParameter(12, java.sql.Types.BIGINT);
        //리턴 파라미터 끝

        //실행
cstmt.execute();

}catch(Exception e){
setTextAppend("등록실패");
setTextAppend(e.toString());
}finally{
if(rs != null){ try{ rs.close(); }catch(SQLException e){} }
if(cstmt != null){ try{ cstmt.close(); }catch(SQLException e){} }
connPool.returnConnection(conn);
}

댓글 없음:

댓글 쓰기

[lunux]리눅스 폴더별 용량 확인

리눅스 폴더별 용량 확인 조회 하고자 하는 디렉토리 리스트가있는 경로로 이동후 du -h --max-depth=1