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

    Date2020.04.09 Byadmin Views4473
    read more
  3. cubrid 설치전 php설치에서

    Date2010.01.03 By뚱기 Views11836
    Read More
  4. CUBRID 2008 R2.0에서 R2.1로 업그레이드 시

    Date2009.12.31 By차오이 Views9625
    Read More
  5. 형변환 오류 문의

    Date2009.12.30 By삽질중 Views12970
    Read More
  6. 큐브리드 메니저 데이터베이스검사시 에러문구

    Date2009.12.30 By까망이 Views9781
    Read More
  7. 데이터베이스 오류문제

    Date2009.12.30 Bypictions Views14120
    Read More
  8. 큐브리드는 mysql 의 varchar(255) 와 동일한 길이가 아니네요?

    Date2009.12.28 By초보 Views22102
    Read More
  9. CUBRID 컨설팅을 받고 싶습니다.

    Date2009.12.28 By오004 Views6
    Read More
  10. 윈도우7+iis(7.5)+php5+cubrid에 xe 설치 후에 초기하면에 빨간색 글들.

    Date2009.12.26 ByHyuk-kwony Views20651
    Read More
  11. 큐브리드 매니저에서 엑셀 데이타 입력시 문제

    Date2009.12.26 By지니보이 Views14
    Read More
  12. 큐브리드에 데이타 타입 지정문제

    Date2009.12.26 By지니보이 Views20203
    Read More
  13. set type 문의

    Date2009.12.25 By초보 Views9862
    Read More
  14. ODBC 연결 방법

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

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

    Date2009.12.23 Byhyperhand Views14060
    Read More
  17. BLOB 데이터 select 질문

    Date2009.12.23 Byhyperhand Views12311
    Read More
  18. Java SP 질문

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

    Date2009.12.22 By지니보이 Views15270
    Read More
  20. AUTO_INCREMENT 컬럼 이용시

    Date2009.12.22 Byhyperhand Views17649
    Read More
  21. java stored procedure 실행시 에러

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

    Date2009.12.21 Byhyperhand Views18158
    Read More
Board Pagination Prev 1 ... 172 173 174 175 176 177 178 179 180 181 ... 200 Next
/ 200

Contact Cubrid

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