반응형

JDBC (Java Data Base Connectivity) 는 자바에서 Database 를 연결하기 위해 제공되는 Core API

MyBatis 는 SQL Mapper의 일종으로 JDBC를 이용해서 DB에 SQL을 실행하는 것에 대한 방식을 개발적인 관점에서 좀 더 편하고 관리하기 쉽게 만든 Wrapper LIB 개념

차를 운전할 때 핸들은 제조사에서 달려 나오지만 사람에 따라서 다양한 형태의 핸들 커버를 씌우기도 하고 손잡이도 달기도 

제조사에서 달려 나온 핸들을 JDBC 라고 생각하시면 MyBatis 같은 LIB들은 핸들커버나 손잡이 정도에 해당하겠네요.

중요한건 핸들만 가지고 운전을 할수는 있지만 핸들없이 핸들커버만 가지고 운전을 할 수는 없다는점을 생각해 보시면 될 것 같습니다.

반응형
반응형

resultType 은 리턴값이 List<?> 여도 DTO, VO, Map 으로 지정해줘야함

반환된 최종값이 아닌 반환될 객체의 타입으로 지정해줘야함

select A from B 같은 경우에는 List<String> 형태일테니 resultType 은 java.lang.String

select A,B from C의 경우,  따로 객체안만드려면 map

반응형

'java, mybatis' 카테고리의 다른 글

mybatis collection, association  (0) 2022.04.27
mybatis  (0) 2022.04.23
mybatis 사용이유  (0) 2022.04.23
mytabis: parameterType, resultType, resultMap  (0) 2022.04.23
mybatis 비교시 주의사항 (=="비교대상"로 써야함)  (0) 2022.04.23
반응형
  • 생산성 - 빠른개발
    • DBCP만 썻을 때 connection, resultSet, statement, transaction 관리도 해야되고 특히 운영하다 명시적인 connection, resultSet, statement, transaction 닫지 않고 잘못 써서 서버 죽는 경우 허다
    • resultSet의 데이터 매핑도 신경써야 하고 소스분석도 어려워짐
  • 보안: SQL injection공격에 신경안써도 됨 (DBCP경우 preparedStatement 쓰면 문제없지만...)
  •  oracle의 경우 blob, clob 치환에 신경안써도 됨
  • 디버깅 쉬워짐: ? => value로 매핑된 쿼리문으로 로그남겨서...
  • 데이터 캐싱(LIFO, FIFO, LRU) 가능
    • 조회용 데이터 성능 안나올때 성능개선 가능, xml 설정만으로 적용가능
  • resultType result class를 VO안쓰고 맵으로 받을 수 있음
반응형

'java, mybatis' 카테고리의 다른 글

mybatis collection, association  (0) 2022.04.27
mybatis  (0) 2022.04.23
mybatis resultType  (0) 2022.04.23
mytabis: parameterType, resultType, resultMap  (0) 2022.04.23
mybatis 비교시 주의사항 (=="비교대상"로 써야함)  (0) 2022.04.23
반응형
  • parameterType:  실제로 넘어오는 actual parameter로 유추가능하기 때문에 생략가능
  • resultType, resultMap
    • resultType: className or alias사용가능
      • java String class에 대한 alias는 string, 그래서 String, string이렇게 대소문자 모두 사용가능한듯
    • resultMap: mapper XML내부에서 정의해서 사용
      • 복잡한 구조로 변경이 필요할 때는   resultMap으로 변환해서 사용하면 좋음
      • 다음과 같이 3단구조로 된 복잡한 애도 아래처럼 매핑해서 사용가능
        • <resultMap id="homeAppTab" type="TabPayload">
              <id property="idx" column="idx"/>
              <result property="status" column="status"/>
              <result property="deviceType" column="device_type"/>
              <result property="region" column="region"/>
              <result property="tabCode" column="tab_code"/>
              <result property="tabName" column="tab_name"/>
              <collection property="tabMultiLangList" ofType="TabMultiLangPayload">
                <id property="idx" column="tabLangIdx"/>
                <result property="tabLangCode" column="tabLangCode"/>
                <result property="tabLangName" column="tabLangName"/>
              </collection>
              <collection property="categoryList" ofType="CategoryPayload">
                <id property="idx" column="categoryIdx"/>
                <result property="categoryCode" column="category_code"/>
                <result property="categoryName" column="category_name"/>
                <result property="categoryOrder" column="category_order"/>
                <collection property="categoryMultiLangList" ofType="CategoryMultiLangPayload">
                  <id property="idx" column="categoryLangIdx"/>
                  <result property="categoryLangCode" column="categoryLangCode"/>
                  <result property="categoryLangName" column="categoryLangName"/>
                </collection>
                <collection property="categoryResultList" ofType="CategoryResultPayload">
                  <id property="idx" column="categoryResultIdx"/>
                  <result property="countryCode" column="country_code"/>
                  <result property="providerId" column="provider_id"/>
                  <result property="contentType" column="result_content_type"/>
                  <result property="contentId" column="content_id"/>
                  <result property="resultOrder" column="result_order"/>
                </collection>
              </collection>
            </resultMap>

 

반응형

'java, mybatis' 카테고리의 다른 글

mybatis collection, association  (0) 2022.04.27
mybatis  (0) 2022.04.23
mybatis resultType  (0) 2022.04.23
mybatis 사용이유  (0) 2022.04.23
mybatis 비교시 주의사항 (=="비교대상"로 써야함)  (0) 2022.04.23
반응형

mybatis java.lang.numberformatexception for input string에러가 난데없이 발생

string을 number로 잘못 변환했다는 건데 그런적이 없는데 왜?? 알고보니 아래와 같은 이유였음 

<if test=status=='P' and status=='p'> -> 'p'를 char -> int로 변환하여 비교시 status도 int로 변환되어 에러남

<if test=status=="P" and status=="p"> ->"p"로 해줘야함

반응형

'java, mybatis' 카테고리의 다른 글

mybatis collection, association  (0) 2022.04.27
mybatis  (0) 2022.04.23
mybatis resultType  (0) 2022.04.23
mybatis 사용이유  (0) 2022.04.23
mytabis: parameterType, resultType, resultMap  (0) 2022.04.23
반응형

FTP

>ftp ftp1.xumo.com //정상적으로 연결되면 Name과 Password를 입력하라고 메세지가 뜸

>ftp 34.194.1.28 //IP로 요청해도 동일함

>quit //중지

> ls //정상적으로 연결되면 ls명령어 치면 Connection accepted 메시지 나오며 데이터를 받아오는데, EIC는 접속은 되지만 그후 실제 데이터 못 받아옴

227 Entering Passive Mode (34,194,1,28,86,75)
150 Connection accepted
drwxr-xr-x 1 ftp ftp 0 Jun 14 23:15 prod
drwxr-xr-x 1 ftp ftp 0 Jun 14 23:14 staging
226 Transfer OK

  • 연결은 정상적으로 되는데 방화벽때문에 그 이후 다운로드나 ls 등 명령어 수행에 에러가 날 수 있음 -> binary mode로 연결이 안되기 때문, FTP 접속포트인 21번과 20번도 같이 방화벽을 열어야함
반응형

'etc > linux' 카테고리의 다른 글

linux 압축  (0) 2022.04.23
chmod  (0) 2022.04.20
.bashrc (alias)  (0) 2022.04.20
linux 시간동기화  (0) 2022.04.18
ls -al 결과의 의미  (0) 2022.04.18
반응형
  • 압축하기
    • tar czvf conory.tar.gz /home/conory
  • 압축풀기
    • tar xzvf conory.tar.gz


반응형

'etc > linux' 카테고리의 다른 글

linux ftp  (0) 2022.04.23
chmod  (0) 2022.04.20
.bashrc (alias)  (0) 2022.04.20
linux 시간동기화  (0) 2022.04.18
ls -al 결과의 의미  (0) 2022.04.18
반응형
  • DB timezone설정이 utc이면 current_timestamp=utc_timestamp이지만, 아니면 다름, 즉, current_timestamp = now() != utc_timestamp
    • select current_timestamp; -- 2022-04-22 16:06:16
      select current_time; -- 16:06:08
      select current_date; -- 2022-04-22
      select utc_timestamp; -- 2022-04-22 07:06:38
      select utc_time; -- 07:06:52
      select utc_date; -- 2022-04-22
      select now(); -- 2022-04-22 16:07:17
  • date, time, timestamp 차이
    • date: 날짜만 보여주고 날짜 정보까지만 가짐
    • time: 시간만 보여주지만 날짜 + 시간정보 모두 가짐
    • timestamp: 시간 full로 보여줌
    • 다음과 같이 function으로도 사용가능
select current_date, date(current_date), time(current_date), timestamp(current_date);
select current_time, date(current_time), time(current_time), timestamp(current_time);
select current_timestamp, date(current_timestamp), time(current_timestamp), timestamp(current_timestamp);
  • 날짜 더하기빼기: +1로 일단위,초단위 가능, 시간단위로 하려면 date_add 써야함
    • select utc_timestamp -- 2022-04-22 07:17:22
      union all
      select utc_timestamp + 1 -- 20220422071651 (+ 1 second)
      union all
      select utc_time + 1 -- 71651 (+ 1 second)
      union all
      select utc_date + 1 -- 20220423 (+ 1 day)
    • select current_timestamp() -- 2022-04-22 16:21:07
      union all
      select current_timestamp + 1 -- 20220422162108 (+ 1 second)
      union all
      select current_time + 1 -- 162108 (+ 1 second)
      union all
      select current_date + 1 -- 20220423 (+ 1 day)
    • select DATE_ADD(current_timestamp, interval 20 hour) -- 2022-04-23 00:00:00
      select DATE_ADD(current_date, interval 1 day)-- 2022-04-23
      select DATE_ADD(now(), interval 1 day)-- 2022-04-23 16:10:08
반응형

'db' 카테고리의 다른 글

mysql 한글깨짐  (0) 2022.04.26
mysql console 접속  (0) 2022.04.26
우분투 18.04 MongoDB 설치 및 구성  (0) 2022.04.18
mysql remote 접속허용  (0) 2022.04.14
mysql numeric type  (0) 2020.11.05
반응형

사용법: chmod [option-생략가능] mode fileName

mode 작성법: read=4, write=2, execute=1

755 = (소유주) 4+2+1, (소유그룹) 4+0+1,  (others) 4+0+1
644 = (소유주) 4+2+0, (소유그룹) 4+0+0, (otehrs) 4+0+0

  • 7 read write execute 모두가능
  • 6 read write 가능하지만 execute불가능
  • 5 read execute 가능 write불가능
  • 4 read 만 가능

 

  • 디렉토리에 대한 execute는 어떤 의미? read write를 하기 위한 기본접근권한, execute없이는 read write도 안된다고 함 즉, 6(rw-)는 실질적으로 의미가 없고 0(---)과 같다는 의미인지??
  • 기본적으로 디렉토리는 755, 파일은 644인 것 같음,  why?

 

  • WAS에서 multipartFile받아서 임시로 내부 디렉토리에 저장하려고 하니 권한에러 발생
  • 권한찾아보니 755였음, 775로 고쳐도 계속 에러남, 777로 고쳐서 성공

 

반응형

'etc > linux' 카테고리의 다른 글

linux ftp  (0) 2022.04.23
linux 압축  (0) 2022.04.23
.bashrc (alias)  (0) 2022.04.20
linux 시간동기화  (0) 2022.04.18
ls -al 결과의 의미  (0) 2022.04.18
반응형

개인 ALIAS 생성

  • home directory의 .bashrc 파일을 vi로 열어서 아래와 같은 aliase 추가가능
  • alias goeic='ssh -i .ssh/key-ew1-sdp-qa2-was-sdpbat.pem sdpbat@10.150.33.137 -p 40022'
    alias goaic='ssh -i .ssh/key-uw2-sdp-qa2-was-sdpbat.pem sdpbat@10.150.33.129 -p 40022'
    alias gokic='ssh -i .ssh/key-an2-sdp-qa2-was-sdpbat.pem sdpbat@10.150.33.156 -p 40022'
  • 수정한뒤 wq로 저장하고 . .bashrc라는 명령어 수행해야 적용됨

alias : 모든 사용가능한 alias확인
alias추가 .bashrc(또는 .bash_aliases파일 만들어서 그안에) 에 alias ()=''로 추가 -> source .bashrc (또는 source ~/.bashrc) [옛날에 정리해놓을 거 보니 ..bashrc도 된다함, 이게 더 간단하니 좋네]-> 이제 사용가능
참고: https://ojava.tistory.com/153

ssh접속시 원하는 디렉토리로 바로 이동
ssh -t x.x.x.x "cd /xx ; bash"로 하면 된다고 하는데 alias로는 안됨 뭔가 더해야하나봄
참고: https://outofgreed.tistory.com/313 https://stackoverflow.com/questions/626533/how-can-i-ssh-directly-to-a-particular-directory

etc/profile ./profile /etc/bashrc .bashrc차이는 뭘까
etc/xx는 전체공통 .xx는 그 계정에서만 유효
profile-system wide environment and startup progams for login setup (환경설정)
bashrc-system wide function and alias (함수나 alias)
각각의 용도에 대해서 vim으로 열어보면 처음에 comment로 나와있음 - 친절하군ㅋ

반응형

'etc > linux' 카테고리의 다른 글

linux 압축  (0) 2022.04.23
chmod  (0) 2022.04.20
linux 시간동기화  (0) 2022.04.18
ls -al 결과의 의미  (0) 2022.04.18
linux 사양확인  (0) 2022.04.18

+ Recent posts