JAva呼び出しoracleのプロシージャ関数


1,戻り値なし+戻り値のあるプロセス
create table book
(bookId number,bookName varchar2(50),publishHouse varchar2(50));
--  
--in:          ,   in    \
--out:
create or replace procedure sp_pro11
(spBookId in number,spbookName in varchar2,sppublishHouse in varchar2) is
begin
  insert into book values(spBookId,spbookName,sppublishHouse);
  end;

--         
create or replace procedure sp_pro12
(spno in number,spName out varchar2,spSal out number,spJob out varchar2) is
 begin 
   select ename,sal,job into spName,spSal,spJob from emp where empno=spno;
   end;

2,java変調関数の書き方(戻り値なし+戻り値あり)
	Class.forName(driver);
			conn=DriverManager.getConnection(strUrl,"scott","tiger");
			
		/*	CallableStatement pro =conn.prepareCall("{call sp_pro11(?,?,?)}");
			pro.setInt(1, 10);
			pro.setString(2, "        ");
			pro.setString(3, "     !");
			pro.execute();
			*/
			
			CallableStatement pro =conn.prepareCall("{call sp_pro12(?,?,?,?)}");
			pro.setInt(1, 7788);
			//  oracle     ;
			pro.registerOutParameter(2, oracle.jdbc.OracleTypes.VARCHAR);
			pro.registerOutParameter(3, oracle.jdbc.OracleTypes.DOUBLE);
			pro.registerOutParameter(4, oracle.jdbc.OracleTypes.VARCHAR);
			pro.execute();
			//     
			String name=pro.getString(2);
			String job = pro.getString(4);
			Double sal = pro.getDouble(3);
			System.out.println("7788   :"+name+"     :"+sal+"    :"+job);
			pro.close();
			conn.close();