Background Image
응용개발
2009.04.11 01:06

jdbc에서 bit 데이터 타입 사용하기

조회 수 15013 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

CUBRID의 bit 데이터 타입을 sql로 처리하는 방법은
insert into test_tb (bittype) values(B'01');
select bittype from test_tb where bittype=B'01';
와 같은 방법으로 저장, 조회 할 수 있습니다.
위와 동일한 작업을 jdbc의 preparestatement 방식을 사용하는 경우에는 setBytes, getBytes를 사용하여야 하고 인자로는 byte[]을 사용하여야 합니다.
위 sql의 B'01'이라는 값을 byte 배열에 저장하려면
byte[] b = new byte[2];
b[0] = (byte)1000000;

preparestatement에 적용 해보면
pstmt = con.prepareStatement("select bittype from test_tb where bittype=?");
pstmt.setBytes(1, b);
rs = pstmt.executeQuery();
while(rs.next()){
System.out.println("result ->" + new String(rs.getBytes(1)));
}

결과는
result -> @
로 나타나게 됩니다.
B'01'이 문자열로 나타내면 @ 였네요.

문자열 @를 byte로 변환하여 적용할 경우에는
byte[] b = "@".getBytes();
를 사용하면 됩니다.


  1. CUBRID 2008 삭제시 제어판에서 삭제되지 않을시 해결법

    Date2009.04.13 Category운영관리 Byseongjoon Views15892
    Read More
  2. jdbc에서 bit 데이터 타입 사용하기

    Date2009.04.11 Category응용개발 By손승일 Views15013
    Read More
  3. 데이터베이스 볼륨 자동 증가 설정

    Date2009.04.01 Category운영관리 By남재우 Views18801
    Read More
  4. 큐브리드매니져를 이용한 데이터베이스 자동 백업

    Date2009.04.01 Category운영관리 By남재우 Views19052
    Read More
  5. CSQL 에서 한글을 입력하는 방법

    Date2009.04.01 Category운영관리 ByPrototype Views19350
    Read More
  6. CUBRID 2008 삭제시 주의사항

    Date2009.04.01 Category운영관리 Byseongjoon Views15288
    Read More
  7. CUBRID 2008 설치시 주의사항

    Date2009.04.01 Category운영관리 Byseongjoon Views17496
    Read More
  8. 32bit 리눅스 환경에서 php 모듈 빌드가 되지 않을 경우

    Date2009.03.31 Category기타 ByPrototype Views17179
    Read More
  9. UTF8 로 저장된 데이터를 매니저로 조회하는 방법

    Date2009.03.21 CategoryCUBRID 매니저 ByPrototype Views25636
    Read More
  10. 데이터 값 작은 따옴표(') 넣기

    Date2009.03.20 Category질의작성 By정만영 Views23809
    Read More
  11. 2008.11.18. 최신 우편번호부 with CUBRID

    Date2009.03.17 Category기타 ByPrototype Views14482
    Read More
  12. 테이블 데이터 복사 하기

    Date2009.03.14 Category질의작성 By정만영 Views22301
    Read More
  13. 컬럼 사이즈 변경 방법

    Date2009.03.14 Category질의작성 By정만영 Views24334
    Read More
  14. 여러 버전의 CUBRID에 CUBRID Manager로 연결하는 방법

    Date2009.03.14 CategoryCUBRID 매니저 By일동차렷? Views15355
    Read More
  15. 다중 row를 하나의 column에 넣기

    Date2009.03.13 Category질의작성 By정만영 Views20088
    Read More
  16. 요일 값을 반환 받을 수 있는 질의 형태

    Date2009.03.13 Category질의작성 By정만영 Views17107
    Read More
  17. CUBRID Manager Client 에러(Java관련).

    Date2009.02.06 CategoryCUBRID 매니저 By윤희서 Views24152
    Read More
  18. 데이터베이스 자동시작 설정(CUBRID 2008 R 1.2).

    Date2009.01.31 CategoryCUBRID 매니저 By윤희서 Views20187
    Read More
  19. 데이터베이스 자동시작 설정(CUBRID 7.3.0).

    Date2009.01.17 CategoryCUBRID 매니저 By윤희서 Views23155
    Read More
  20. CUBRID 하위버젼에서 CUBRID2008로의 업그레이드 방법

    Date2008.12.06 Category마이그레이션 By남재우 Views30154
    Read More
Board Pagination Prev 1 ... 5 6 7 8 9 10 11 12 13 14 Next
/ 14

Contact Cubrid

대표전화 070-4077-2110 / 기술문의 070-4077-2113 / 영업문의 070-4077-2112 / Email. contact_at_cubrid.com
Contact Sales