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. SQLGate for CUBRID 영구 무료 라이선스 제공

    Date2020.04.09 Byadmin Views4251
    read more
  2. A serial object already exists as an auto increment constraint. 오류 질문

    Date2013.10.28 Bykimsuny Views15983
    Read More
  3. ACTIVE_SESSION 이 48수치에 DB 다운되어 버립니다.

    Date2010.07.25 By안토니오 Views10901
    Read More
  4. ACXEL_Installer를 이용할려는데

    Date2010.12.20 BySoMa Views7716
    Read More
  5. ADD AFTER, FIRST 명령어와 ALTER MODIFY, CHANGE 문제

    Date2017.03.01 By무냉채 Views9432
    Read More
  6. ADD_MONTHS 함수의 사용

    Date2009.06.25 By체리필터 Views16164
    Read More
  7. ADO update관련 문의드립니다.

    Date2014.01.26 BySD2 Views7686
    Read More
  8. ADO.NET "Invalid buffer position!" 오류

    Date2014.07.17 By할리 Views7520
    Read More
  9. ADO.NET 4.5 SQL query의 칼럼이름가져오기

    Date2017.09.06 Byallis Views386
    Read More
  10. ADO.NET Connector 문의

    Date2021.08.31 By까망이 Views65
    Read More
  11. ADO.NET cascci.dll 64Bit 관련

    Date2015.11.06 By할리 Views6141
    Read More
  12. ADO.NET cascci.dll 64Bit, field name/type 오류

    Date2016.01.21 By할리 Views6627
    Read More
  13. ADO.NET columninfos 반환값 관련 문의

    Date2020.05.26 ByJs Views108
    Read More
  14. ADO.NET columninfos 반환값 관련 문의

    Date2020.05.18 ByJs Views165
    Read More
  15. ADO.NET dll 참조

    Date2018.10.04 Byabc12 Views891
    Read More
  16. ADO.NET 관련 질문

    Date2015.10.30 By할리 Views6442
    Read More
  17. ADO.NET 드라이버 집합형 데이터 지원

    Date2012.02.09 By소라게 Views39855
    Read More
  18. ADO.NET 에러

    Date2021.09.14 By둠둠둠 Views66
    Read More
  19. ADO.NET 에서 connection pool 사용 가능한가요?

    Date2022.11.04 By시나브로 Views27
    Read More
  20. ADO.NET 을 비쥬얼 스튜디오에 연결하기...

    Date2012.02.12 By희나람 Views11728
    Read More
  21. ADO.NET에서 자바 저장함수 호출

    Date2014.11.01 Bykdknim21 Views8420
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 199 Next
/ 199

Contact Cubrid

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