Background Image

FORUM

?

단축키

Prev이전 문서

Next다음 문서

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

* 질문 등록 시 다음의 내용을 꼭 기입하여 주세요.
OS
Window7 32bit, Linux 64bit 등
CUBRID Ver.
[cubrid_rel] 수행 결과
CUBRID TOOL Ver.
[도움말]-[버전정보] 확인
응용 환경(API)
java, php, odbc 등 입력

* CUBRID 응용 오류, SQL 오류 또는 SQL 튜닝 관련된 문의는 반드시 다음의 내용을 추가해 주세요. 비밀글이나 비밀 댓글도 가능합니다.
* 저희가 상황을 이해하고, 재현이 가능해야 알 수 있는 문제들이 많습니다. 가능한 정보/정황들을 부탁합니다.
에러 내용 및 재현 방법 재현 가능한 Source와 SQL
관련 테이블(인덱스, 키정보 포함) 정보 CUBRID 홈 디렉토리 아래 log 디렉토리 압축


-------------- 아래에 질문 사항을 기입해 주세요. ------------------------------------------------------------------------


BLOB 타입 이미지를 JSP로 웹에 뿌려주려면 어떻게 해야하나요?

SQL은 다음과 같이 했습니다.


SELECT 

BLOB_TO_BIT(mem_img)

FROM 

member

  • ?
    김승훈 2014.07.08 20:37

    안녕하세요. 큐브리드를 사랑해주셔서 감사합니다.


    제가 해결한 방법을 말씀드리자면요.


    서블릿 클래스 하나를 생성하여서 blob 컬럼을 조회 해서

    ServletOutputStream 객체에 write하는 방식으로 처리했습니다.


    예제 소스코드는 아래와 같습니다.


     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    response.setContentType("image/jpeg");

    int num = Integer.parseInt(request.getParameter("num")); // blob 테이블의 index 번호입니다.

    String className = "cubrid.jdbc.driver.CUBRIDDriver";

    String url = "jdbc:cubrid:<ip>:<port>:<db_name>:<id>:<pwd>:";

    String sql = "select blob from blob_tbl where id=?"; // blob을 조회하는 쿼리입니다.

    Connection conn = null;

    PreparedStatement pstmt = null;

    ResultSet rs = null;

    Blob blob = null; // blob 데이터를 저장할 객체 생성

    ServletOutputStream sOut = response.getOutputStream(); // 이미지를 출력할 outputStream 객체 생성

    try {

    Class.forName(className);

    conn = DriverManager.getConnection(url);

    System.out.println("conn : " + conn);

    pstmt = conn.prepareStatement(sql);

    pstmt.setInt(1, num);

    rs = pstmt.executeQuery();

    if(rs.next()) {

    blob = rs.getBlob(1); // blob 객체에 blob 데이터 저장

    }

    sOut.write(blob.getBytes(1, (int)blob.length())); // outputStream 객체에 blob 객체를 byte[] 로 만들어서 쓰기

    } catch (Exception e) {

    e.printStackTrace();

    } finally {

    try {

    if(sOut != null) sOut.close();

    if(rs != null) rs.close();

    if(pstmt != null) pstmt.close();

    if(conn != null) conn.close();

    } catch (SQLException e) {

    e.printStackTrace();

    }

    }

    }


    위와 같은 소스코드로 서블릿 클래스를작성하여 web.xml 파일에 등록 후

    jsp 페이지에서 호출하면 정상적으로 이미지가 출력됩니다.


    감사합니다.


  1. CUBRID 사용자를 위한 DBeaver 도구 출시 안내

    Date2024.04.23 Byadmin Views42
    read more
  2. SQLGate for CUBRID 영구 무료 라이선스 제공

    Date2020.04.09 Byadmin Views4458
    read more
  3. ADO.NET에서 자바 저장함수 호출

    Date2014.11.01 Bykdknim21 Views8420
    Read More
  4. ADO.Net 사용중입니다. 상태확인 방법을 알고 싶습니다.

    Date2015.10.22 ByCUCUCUCU Views5691
    Read More
  5. ADO.net Driver 변경 시 cascci.dll 로드할 수 없다는 오류

    Date2017.07.25 By물병 Views503
    Read More
  6. ADO.net 또는 ODBC에 대한 질문입니다.

    Date2012.03.20 By세스카 Views13377
    Read More
  7. ADO이용시 OLEDB Driver에러

    Date2010.01.29 Byflypig Views15619
    Read More
  8. AIX에 CUBRID 설치 후 오류사항 문의

    Date2015.06.02 By최명호 Views7735
    Read More
  9. ALTER 로 PK 여러 개 지정하고싶습니다

    Date2021.07.21 By사탕구름 Views831
    Read More
  10. ARRAY 데이터 타입에 대한 SQL 질문

    Date2010.10.08 By지용 Views10246
    Read More
  11. AUTO INCREASE 가 편집이 안됨

    Date2022.02.08 By큐브리드어려워요 Views268
    Read More
  12. AUTO_INCREMENT 수동 증가 문의

    Date2021.08.19 Bycubrid초보 Views727
    Read More
  13. AUTO_INCREMENT 컬럼 이용시

    Date2009.12.22 Byhyperhand Views17649
    Read More
  14. AVG 함수관련 질문드려요

    Date2013.06.10 By구름마음 Views13678
    Read More
  15. Ado.NET : Cannot connect to CUBRID CAS 오류

    Date2017.05.05 Bywebsiter Views57857
    Read More
  16. Ado.net. ExecuteNonQuery의 반환값이 항상 0 입니다.

    Date2019.01.08 By모비23 Views1479
    Read More
  17. An IOException was caught during reading the inputstream

    Date2015.11.26 By익명2 Views6872
    Read More
  18. An IOException was caught during reading the inputstream

    Date2015.11.26 By익명2 Views6829
    Read More
  19. An IOException was caught during reading the inputstream. 오류 조치방법 좀 알려주세요.

    Date2019.10.29 Byldev27 Views314
    Read More
  20. An internal error occurred during: "Fetching children of <DB명>". java.lang.NullPointerException 에러

    Date2021.04.06 Byysh Views481
    Read More
  21. Apm_setup7로 자동설치시 연동이 안되는데...

    Date2010.11.08 By또랑 Views8277
    Read More
  22. Archive Log만으로 타임복구가 가능한가요?

    Date2016.04.29 By핑핑크 Views9820
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 ... 200 Next
/ 200

Contact Cubrid

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