3초기억력

Spring) gradle, mybatis mapper.xml 에서 like 쿼리시 주의점 본문

자바_Spring

Spring) gradle, mybatis mapper.xml 에서 like 쿼리시 주의점

잠수콩 2021. 4. 9. 15:24
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

1. Oracle 11g xe : project[EMP]

- build.gradle

dependencies {
  implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.4'
  runtimeOnly 'com.oracle.database.jdbc:ojdbc8'
}

- application.properties

spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.url=jdbc:oracle:thin:@localhost:1521:xe
spring.datasource.username=scott
spring.datasource.password=tiger

- EmpMapper.xml

<mapper namespace="com.devtory.emp.dao.EmpDao">
  <select id="empList" resultType="com.devtory.emp.vo.Emp" parameterType="com.devtory.emp.vo.Emp">
    select * from emp where ename like '%'||#{ename}||'%' and job like '%'||#{job}||'%'
  </select>
</mapper>

2. MySql 5.5 : project[gusto]

- build.gradle

dependencies {
  implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.4'
  runtimeOnly 'mysql:mysql-connector-java'
}

- application.properties

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/gusto?serverTimezone=Asia/Seoul&characterEncoding=UTF-8
spring.datasource.username=userid
spring.datasource.password=userpw

- BlogMapper.xml

<mapper namespace="com.devtory.emp.dao.EmpDao">
  <select id="empList" resultType="com.devtory.emp.vo.Emp" parameterType="com.devtory.emp.vo.Emp">
    select * from blog
    where title like CONCAT('%', #{title}, '%')
        and short_description like CONCAT('%', #short_description}, %')

  </select>
</mapper>

 

 

'자바_Spring' 카테고리의 다른 글

intro.jsp 생성 및 서버 설치  (0) 2021.03.02
첫 프로젝트 생성하기  (0) 2021.03.02
이클립스 설정  (0) 2021.03.02
자바 설치 및 이클립스 설치  (0) 2021.03.02
Comments