CAFE

함께풀어보기

Re: Model1 및 MyBatis 복습 정리를 답글로 올리기(팀별)

작성자윤희상|작성시간26.06.16|조회수21 목록 댓글 0
context.xml

DB 접속을 위한 정보가 들어있는 파일입니다

 

 

ConnUtils.java

MET-INF/context.xml을 자동으로 찾아 읽어와서 DB 커넥션 연결 객체를 반환하는 클래스

 

 

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE mapper

PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"

"https://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="board">

<!-- insert 문

#{property} vo.BoardVO getter

#{subject} => vo.getSubject();

-->

 

<insert id="save" parameterType="ex2.BoardVO">

INSERT INTO BOARD VALUES(board_seq.nextVal,#{title},#{writer},#{content},#{pwd},0,#{reip},sysdate)

</insert>

 

<select id="list" resultType="ex2.BoardVO">

SELECT no,title,writer,content,hit,regdate FROM BOARD ORDER BY 1 DESC

</select>

 

<update id="hit" parameterType="int">

update board set hit=hit+1 where no=#{no}

</update>

 

<select id="detail" parameterType="int" resultType="ex2.BoardVO">

SELECT no,title,writer,hit,content,reip,regdate FROM BOARD WHERE no=#{no}

</select>

 

<select id="checkpass" parameterType="ex2.BoardVO" resultType="int">

select count(*) as cnt from board where no=#{no} AND pwd=#{pwd}

</select>

 

<select id="getUpdateDelete" parameterType="int" resultType="ex2.BoardVO">

SELECT no,title,writer,hit,content,pwd,reip,regdate FROM BOARD WHERE no=#{no}

</select>

 

<update id="updateBoard" parameterType="ex2.BoardVO">

update board set title=#{title}, writer=#{writer}, content=#{content}, pwd=#{pwd}, reip=#{reip}, regdate=sysdate where no=#{no}

</update>

 

<delete id="RemoveBoard" parameterType="int">

delete from board where no=#{no}

</delete>

</mapper>

 

boardMap.xml

 

쿼리코드 축약

 

 

BoardDao.java

DB에서 데이터를 가져오는 메서드들

 

 

다음검색
현재 게시글 추가 기능 열기

댓글

댓글 리스트
맨위로

카페 검색

카페 검색어 입력폼