STEP1:
CREATE OR REPLACE JAVA SOURCE NAMED "Employee" AS
import java.sql.*; import oracle.jdbc.*; public class Employee{ public static void getItEmps(){ Connection conn = null; PreparedStatement pst = null; ResultSet rs = null; try{ conn = DriverManager.getConnection("jdbc:default:connection:"); String sql = "select * from sys.employee where e_id > 1000"; pst = conn.prepareStatement(sql); rs = pst.executeQuery(); while(rs.next()){ System.out.println(rs.getString(1) + "\t" + rs.getString(2)); } }catch(Exception e){ System.err.println(e); }finally{ try{ rs.close(); pst.close(); conn.close(); }catch(Exception e){ System.err.println(e); } } } }
STEP2:
create or replace procedure get_it_emps AS LANGUAGE JAVA NAME 'Employee.getItEmps()';