728x90
반응형
Oracle home 폴더에 Procedure 작성
create or replace procedure id_pw(p_sid member.id%type, p_ppw out member.pw%type)
is
begin
select pw
into p_ppw
from member
where id=p_sid;
end;
/
java 파일 작성
import java.sql.*;
public class StoredProcedure {
public static void main(String[] args) throws Exception{
try{
Connection conn=DBConn.getConnection();
CallableStatement cstmt=conn.prepareCall("{call id_pw(?,?)}");
cstmt.setString(1,"kim1");
cstmt.registerOutParameter(2,java.sql.Types.VARCHAR);
cstmt.execute();
System.out.println(cstmt.getString(2));
cstmt.close();
conn.close();
}catch(Exception e){
System.out.println(e);
}
}
}
create or replace procedure id_pw(p_sid member.id%type, p_ppw out member.pw%type)
is
begin
select pw
into p_ppw
from member
where id=p_sid;
end;
/
java 파일 작성
import java.sql.*;
public class StoredProcedure {
public static void main(String[] args) throws Exception{
try{
Connection conn=DBConn.getConnection();
CallableStatement cstmt=conn.prepareCall("{call id_pw(?,?)}");
cstmt.setString(1,"kim1");
cstmt.registerOutParameter(2,java.sql.Types.VARCHAR);
cstmt.execute();
System.out.println(cstmt.getString(2));
cstmt.close();
conn.close();
}catch(Exception e){
System.out.println(e);
}
}
}
728x90