database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
PostgreSQL
Firebird
ㆍOracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
Oracle Q&A 922 게시물 읽기
No. 922
Servlet에서 PL/SQL부르기 좀 알려주세요.
작성자
전진우
작성일
2000-06-05 10:32
조회수
8,455

게시판을 만들려고 합니다.

pl/sql로 처리 할려고 하는데요.

 

create procedure test

(

a_no in announce.no%type

)

is

 

r_announce announce%rowtype;

 

begin

 

dbms_output.enable;

 

select *

into r_announce

from announce

where no = a_no;

 

dbms_output.put_line('No : ' || r_announce.no);

dbms_output.put_line('Title : ' || r_announce.title);

 

end test;

/

 

지금은 이런 pl/sql을 사용해서 테스트 하거든여.

table은 다음과 같고...

 

create table announce

(

no number not null,

title varchar2(50) not null,

content long not null,

day date not null,

viewcount number not null,

primary key (no)

)

/

 

sqlplus에서

 

SQL> execute test(1)

 

하면 결과가 나옵니다.

이걸 servlet에서 결과를 받아 볼 수 있었으면 하느데요.

어떻게 하면 좋을까요?

prepareCall과 CallableStatement를 사용해서 오류없이 실행을 했는데요.

결과 값은 어떻게 얻어 내는지 잘 모르겠습니다.

도와 주세요.

 

소스는 다음과 같구요.

 

public class test2

{

public static void main(String args[])

throws SQLException, ClassNotFoundException, UnsupportedEncodingException

{

Connection conn = null;

ResultSet result = null;

CallableStatement testproc = null;

String data = null;

 

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

Class.forName("oracle.jdbc.driver.OracleDriver");

conn = DriverManager.getConnection("jdbc:oracle:oci8:board/board@LaonDB");

 

if(conn == null)

System.out.println("fail");

else

{

System.out.println("success");

testproc = conn.prepareCall("{call test(?)}");

testproc.setString(1, "1");

testproc.execute();

if(testproc.getResultSet() == null)

System.out.println("result set is null.");

}

 

if(result != null)

{

result.close();

result = null;

}

if(testproc != null)

{

testproc.close();

testproc = null;

}

if(conn != null)

{

conn.close();

conn = null;

}

}

}

 

 

이거 샐행하면 다음과 같이 나옵니다.

[root@localhost temp]# java test2

success

result set is null.

[root@localhost temp]#

[Top]
No.
제목
작성자
작성일
조회
926(참고) Error while trying to retrieve text for error... 메시지에 관하여
Firebird
2000-06-06
8295
924ora-12546 error갈켜주세요..^^
희서니
2000-06-06
7988
929┕>Re: ora-12546 error갈켜주세요..^^
소몰이
2000-06-06 17:51:37
9202
923Servlet에서 Oracle 자료 읽었을때 한글이 깨지는데요?
전진우
2000-06-05
7916
925┕>Re: Servlet에서 Oracle 자료 읽었을때 한글이 깨지는데요?
Firebird
2000-06-06 05:16:56
8611
931 ┕>Re: Re: Servlet에서 Oracle 자료 읽었을때 한글이 깨지는데요?
전진우
2000-06-07 09:06:30
9065
922Servlet에서 PL/SQL부르기 좀 알려주세요.
전진우
2000-06-05
8455
918급해요! 해결하신분 자세한 설명 부탁..
leezion
2000-06-04
8274
917급! 급! 급! (oracle8.1.6 설치)
leezion
2000-06-04
8143
920┕>Re: 급! 급! 급! (oracle8.1.6 설치)
정재익
2000-06-05 00:47:18
9522
916oracle8.1.6.1 설치시 error
leezion
2000-06-04
8895
921┕>Re: oracle8.1.6.1 설치시 error
정재익
2000-06-05 03:41:15
10483
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.021초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다