码迷,mamicode.com
首页 > 数据库 > 详细

ORACLE创建Java过程

时间:2015-03-28 17:18:01      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:




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()‘;


ORACLE创建Java过程

标签:

原文地址:http://blog.csdn.net/zzd1989812/article/details/44702931

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!