Background Image

FORUM

2009.12.23 00:37

Java SP 질문

조회 수 11178 추천 수 0 댓글 9
?

단축키

Prev이전 문서

Next다음 문서

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

아래와 같이 Stored Procedure를 작성했습니다.

import java.util.Date;
import java.text.SimpleDateFormat;
import java.io.ByteArrayInputStream;
import java.sql.*;

public class SP_Insert
{
 public static void InsertData(int sz1, int sz2, int sz3) throws SQLException
 {
  try
  {   
   String sql = "INSERT INTO TBL_DATA_LOG(FLD_DATE, FLD_DATA_SIZE, FLD_DATA, FLD_SZ1, FLD_SZ2, FLD_SZ3) VALUES (?, ?, ?, ?, ?, ?)";
   
   Class.forName("cubrid.jdbc.driver.CUBRIDDriver");
   Connection con = DriverManager.getConnection("jdbc:default:connection:::");
   PreparedStatement pstmt = con.prepareStatement(sql);
   
   Date da = new Date();
   SimpleDateFormat dt = new SimpleDateFormat("yyyyMMddHHmmss");
   String today = dt.format(da);
   
   byte[] cdata = new byte[10];
   
   for(int i=0; i<10; i++)
   {
    cdata[i] = 0x02;
   }
   
   pstmt.setString(1, today);
   pstmt.setInt(2, 10);
   
   ByteArrayInputStream bas = new ByteArrayInputStream(cdata, 0, 10);
   pstmt.setBinaryStream(3, bas, 10);
   
   pstmt.setInt(4, sz1);
   pstmt.setInt(5, sz2);
   pstmt.setInt(6, sz3);
   
   pstmt.executeUpdate();
   
   pstmt.close();
   con.close();
  }
  catch(Exception e)
  {
   System.err.println(e.getMessage());
  }
 }
}

컴파일후 "loadjava TBL_Test SP_Insert.InsertData" 명령으로 클래스 파일을 로딩했구요.
그리고 아래의 명령으로 등록했습니다.
CREATE PROCEDURE InsertData
(
 sz1 integer,
 sz2 integer,
 sz3 integer
)
as LANGUAGE JAVA
NAME 'SP_Insert.InsertData(int, int, int)';

여기까진 정상적으로 수행되는데
"call InsertData(1, 2, 3);" 명령으로 프로시저를 호출하면 아래와 같은 에러가 발생합니다.

Execute: Methods require an object as their target. call InsertData(2, 3) on 1

원인이 뭘까요?


  • ?
    seongjoon 2009.12.23 01:25
    CREATE PROCEDURE InsertData
    (
     sz1 int,
     sz2 int,
     sz3 int
    )
    as LANGUAGE JAVA
    NAME 'SP_Insert.InsertData(int, int, int)';
    와 같이 integer 부분을 int로 바꿔서 해보시길 바랍니다.
  • ?
    hyperhand 2009.12.23 01:36
    integer를 모두 int로, 반대로 int를 모두 integer로 변경해봤는데 똑같은 에러 메시지가 발생합니다ㅜㅜ
  • ?
    seongjoon 2009.12.23 02:02
    해당 테이블의 스키마를 알려주시면 문제 해결에 도움이 될 것으로 보입니다.
  • ?
    hyperhand 2009.12.23 02:19
    아래처럼 테이블을 생성했습니다.
    CREATE TABLE TBL_DATA_LOG
    (
     FLD_DATE CHAR(28) NOT NULL,
     FLD_DATA_SIZE INTEGER NOT NULL,
     FLD_DATA BIT VARYING(2048) NOT NULL,
     FLD_SZ1 INTEGER NOT NULL,
     FLD_SZ2 INTEGER NOT NULL,
     FLD_SZ3 INTEGER NOT NULL,
     CONSTRAINT FK1_TBL_DATA_LOG FOREIGN KEY(FLD_SZ3) REFERENCES TBL_PROTOCOL(FLD_PROTOCOL_SN)
    )
  • ?
    seongjoon 2009.12.23 03:40
    다음과 같이 해보시길 바랍니다.
    1) loadjava TBL_Test SP_Insert.class
    2) SP 등록
    CREATE PROCEDURE InsertData
    (
     sz1 int,
     sz2 int,
     sz3 int
    )
    as LANGUAGE JAVA
    NAME 'SP_Insert.InsertData(int, int, int)';
    3 )call InsertData(1, 2, 3);
  • ?
    hyperhand 2009.12.23 04:09
    제가 처음 질문드릴때 오타 부분이 있었네요ㅜㅜ;
    클래스 로드할 때
    loadjava -y TBL_Test SP_Insert.class 이렇게 했었네요.

    글구 이미 위 방법으로 해봤었습니다. 해보고 질문을 올리기 시작했죠^^
    오타부분 말고는 제가 해본거랑 딱히 달라보이는 부분이 없는데 어디가 다른건가요?
  • ?
    seongjoon 2009.12.23 04:11 SECRET

    "비밀글입니다."

  • ?
    hyperhand 2009.12.23 05:31
    혹시나 싶어서 데이터베이스 싹 다 날리고 처음부터 다시 데이터베이스 생성하고,
    테이블 생성하고, Stored Procedure 다시 로드 및 등록하니 이젠 되네요^^
    궁금한게 있는데요,
    이전에 loadjava 명령으로 데이터베이스에 로드했던 클래스를 언로드하는 방법이 있나요?
    이전에 문제가 있었던 클래스에 loadjava -y 옵션으로 계속 덮어써서 그런게 아닌가 싶은 생각이 들어서요.
    아무튼 도와주셔서 감사합니다^^
  • ?
    seongjoon 2009.12.23 09:03
    loadjava 관련 질문을 472번 글에서 답변해 드렸어요.

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

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

    Date2020.04.09 Byadmin Views4458
    read more
  3. 접속자의 아이피나 맥어드레스를 알아낼수 있는지요

    Date2012.12.05 By유니콘 Views10956
    Read More
  4. 초보 질문드립니다^^:(인스턴스 갱신)

    Date2009.03.12 By박동진 Views10961
    Read More
  5. 맥에서 cubrid query browser 실행이 안됩니다.

    Date2014.03.29 Byzbqmflem12345 Views10964
    Read More
  6. cubridmanager 실행시 오류 입니다.

    Date2010.12.11 By하하보이 Views10970
    Read More
  7. 원하는 테이블에 데이터를 추가 하고싶으면 어떻게 하나요?

    Date2009.03.25 By나동호 Views10981
    Read More
  8. 매니저 오류 문의

    Date2014.01.06 ByKai Views10991
    Read More
  9. 오류의 의미??

    Date2016.06.21 By천상 Views10992
    Read More
  10. 임시테이블에 대한 지원 계획은 있는지 궁금합니다

    Date2010.07.28 By김종언 Views10994
    Read More
  11. 뷰 테이블 편집 cascade 오류

    Date2010.03.06 By초보 Views11003
    Read More
  12. Cubrid 2008 R 1.3 설치중 에러메시지

    Date2009.03.23 By동진 Views11008
    Read More
  13. 라이센스 관련 문의 입니다.

    Date2011.01.25 Byfoxman Views11011
    Read More
  14. cubrid 8.4.3 loaddb 또는 대량데이터 일괄 Insert 방법

    Date2013.03.22 By김상윤 Views11018
    Read More
  15. 트랙잭션이 시스템에 의해 중단됩니다.

    Date2011.05.26 By김현성 Views11019
    Read More
  16. 대용량 mysql 데이타를 큐브리드 2008 로 마이그레이션 할때

    Date2010.01.27 By초보 Views11023
    Read More
  17. cubrid 설치 후 서버 기동 문제

    Date2009.10.13 By너와나 Views11025
    Read More
  18. JBoss 7.1.1 와 Cubird 9.3.6 버젼 연동 문의

    Date2016.07.12 By뽀대남 Views11060
    Read More
  19. 파티션 테이블에 대해서..

    Date2014.01.17 By알칸펠 Views11067
    Read More
  20. The size of data received from server is different from the expected

    Date2011.01.21 By사자 Views11069
    Read More
  21. 큐브리드 매니저에서 서브쿼리 날리면 값이 안나오는 문제

    Date2010.01.29 By지니보이 Views11071
    Read More
  22. Oracle --> Cubrid 쿼리 변경 질문입니다!

    Date2016.06.01 By잘하자! Views11071
    Read More
Board Pagination Prev 1 ... 149 150 151 152 153 154 155 156 157 158 ... 200 Next
/ 200

Contact Cubrid

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