오류 내용 : org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database may be already in use
해결 방법 :
H2 콘솔 페이지에서 연결을 해제하고 하면 오류가 발생하지 않았다. 하지만 H2 콘솔과 인텔리제이에서 동시에 접속이 가능해야 했기때문에 방법을 찾아보았고, 해결 방법은 다음과 같았다.
application.properties
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
#spring.datasource.url=jdbc:h2:~/Db명 # 수정 전
spring.datasource.url=jdbc:h2:tcp://localhost/~/Db명 # 수정 후
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
<select id="Dao랑 매핑시킬 ID" parameterType="파라미터 type" resultType="반환할 결과 type">
SELECT CONCAT(T1.컬림A, ' > ', T1.컬럼B) FROM 테이블 T1
</select>
위와 같이 xml 파일에 쿼리문을 작성 할 떄, 다음과 같은 오류가 발생하게 됩니다.
Multiple annotations found at this line:
- The content of elements must consist of well-formed character data or markup.
- Start tag of element <select>
해당 오류가 발생하는 이유는 XML 에서 부등호를 문자열이 아닌 <select> </select>와 같이 시작과 끝을 알리는 TAG로 인식하기 때문입니다.
<!-- 조회수 올리기 -->
<update id="updatereviewcnt">
update reviewTable set reCnt = reCnt + 1 where reNum = #{reNum}
</update>
update문으로 조회수(reCnt)를 1씩 증가시켜주도록 합니다.
reviewmapper.java
// 문의글 조회수 올리기
public int updatereviewcnt(String reNum);
reviewService.java
// 조회수 올리기
public int updatereviewcnt(String reNum) throws Exception {
return reviewmapper.updatereviewcnt(reNum);
}
reviewController.java
// 게시글 자세히보기
@RequestMapping(value="/detailreview")
public ModelAndView detail(@RequestParam("reNum") String reNum) throws Exception {
// 기존의 게시글 자세히 보기에서 추가된 부분
reviewservice.updatereviewcnt(reNum);
return new ModelAndView("detail","detail1",reviewservice.detail(reNum));
}
// 추가된 부분
// reviewservice.updatereviewcnt(reNum);