Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
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
more
Archives
Today
Total
관리 메뉴

WON.dev

CDaoImpl.java 본문

JSP/JSP.sideproject

CDaoImpl.java

GAWON 2023. 6. 23. 12:12
package org.joonzis.dao;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.joonzis.mybatis.config.DBService;
import org.joonzis.vo.CVO;

public class CDaoImpl implements CDao{
	// DAO 객체 생성
	private static CDaoImpl instance = null;
	private CDaoImpl() {}
	public static CDaoImpl getInstance() {
		if(instance == null) {
			instance = new CDaoImpl();
		}
		return instance;
	}
	
	// 필드
	private static SqlSession sqlsession = null;
	private synchronized static SqlSession getSqlSession() {
		if(sqlsession == null) {
			sqlsession = DBService.getFactory().openSession(false);
		}
		return sqlsession;
	}
	
	@Override
	public int commentCountByIdx(int b_idx) {
		return getSqlSession().selectOne("comment_count_by_idx", b_idx);
	}
	@Override
	public int insertComment(CVO cvo) {
		int result = getSqlSession().insert("insert_comment", cvo);
		if(result > 0) {
			getSqlSession().commit();
		}
		return 0;
	}
	@Override
	public List<CVO> getCommentList(int b_idx) {
		return getSqlSession().selectList("select_comm_by_bidx", b_idx);
	}
	@Override
	public void removeComment(int c_idx) {
		int result = getSqlSession().delete("delete_comm_by_cidx", c_idx);
		if(result > 0) {
			getSqlSession().commit();
		}
	}
	@Override
	public void removeCommentAll(int b_idx) {
		int result = getSqlSession().delete("delete_all_comm", b_idx);
		if(result > 0) {
			getSqlSession().commit();
		}
	}
}

'JSP > JSP.sideproject' 카테고리의 다른 글

MDaoImpl.java  (0) 2023.06.23
MDao.java  (0) 2023.06.23
CDao.java  (0) 2023.06.23
BDaoImpl.java  (0) 2023.06.23
BDao.java  (0) 2023.06.23