Background Image

FORUM

2009.12.23 00:37

Java SP 질문

조회 수 14126 추천 수 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 Views144004
    read more
  2. ODBC 연결 방법

    Date2009.12.24 By포세이돈 Views15092
    Read More
  3. cent OS 5.4v 에 큐브리드 설치후 서비스 시작 문제..

    Date2009.12.24 By춘식 Views17035
    Read More
  4. 이진 데이터를 Stored Procedure에 넘기는 방법

    Date2009.12.23 Byhyperhand Views17169
    Read More
  5. BLOB 데이터 select 질문

    Date2009.12.23 Byhyperhand Views16123
    Read More
  6. Java SP 질문

    Date2009.12.23 Byhyperhand Views14126
    Read More
  7. 이중 루프문 안에 쿼리문 실행시 바깥루프 안도는 문제

    Date2009.12.22 By지니보이 Views18326
    Read More
  8. AUTO_INCREMENT 컬럼 이용시

    Date2009.12.22 Byhyperhand Views20750
    Read More
  9. java stored procedure 실행시 에러

    Date2009.12.22 Byhyperhand Views26330
    Read More
  10. c#과 cubrid2008 연동후 문자열 select 질문.

    Date2009.12.21 Byhyperhand Views21341
    Read More
  11. R1.4->R2.0(64비트)베타 업그레이드 및 마이그레이션후 DB접속불가.

    Date2009.12.21 Byxclass Views15022
    Read More
  12. Client만 설시치 oledb provider가 설치되지 않습니다.

    Date2009.12.19 Byhyperhand Views16505
    Read More
  13. 오라클과의 성능에 대한 비교를 알고 싶습니다.

    Date2009.12.16 By오004 Views11
    Read More
  14. 오라클과의 호환성과 대용량 검색 속도

    Date2009.12.16 By오004 Views29138
    Read More
  15. 조인 관련 질문입니다.

    Date2009.12.16 By지니보이 Views13001
    Read More
  16. cubrid_prepare()로 데이타 입력시 질문입니다.

    Date2009.12.16 By지니보이 Views12910
    Read More
  17. row level lock 이 지원되나요?

    Date2009.12.16 By초보대왕 Views16158
    Read More
  18. 한글이 깨지네요

    Date2009.12.16 By썬해바라기 Views13599
    Read More
  19. restordb를 사용후 다른 문구가...

    Date2009.12.15 By썬해바라기 Views12621
    Read More
  20. Unloaddb의 문제점

    Date2009.12.14 By앵벌이 Views12711
    Read More
  21. mysql로 마이그레이션하는방법좀..

    Date2009.12.14 By썬해바라기 Views14015
    Read More
Board Pagination Prev 1 ... 185 186 187 188 189 190 191 192 193 194 ... 213 Next
/ 213

Contact Cubrid

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