手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

PL/SQL调用JAVA获取网卡MAC地址

[日期:2013-04-27] 来源:Linux社区  作者:edcvf3 [字体:大 中 小]

主要是学习PL/SQL调用JAVA的方法.

平台:WINDOWS

1.首先用PL/SQL创建好JAVA 源文件(JAVA source)并进行编译,直到没有错误.

注意调用一些外部JAVA 包的时候,编译的时候可能不报错,直到你执行函数的时候才会错误,错误信息一般为:ORA-29540

create or replace and compile java source named getosmac as
import java.io.*;

public class GetOSMac{
    /**
    * 获取MAC地址
    */
    public static String getMac() {
        String result = "";
        try {

            Process process = Runtime.getRuntime().exec("ipconfig /all");--通过执行dos命令IPCONFIG /ALL来获取

            InputStreamReader ir = new InputStreamReader(
                    process.getInputStream());

            LineNumberReader input = new LineNumberReader(ir);

            String line;

            while ((line = input.readLine()) != null)

                if (line.indexOf("Physical Address") > 0) {

                    String MACAddr = line.substring(line.indexOf("-") - 2);

                    result = MACAddr;

                }

        } catch (java.io.IOException e) {

            System.err.println("IOException " + e.getMessage());

        }
        return result;
    }

    public static void main(String[] args) {
        System.out.println("OK!!!"};

}

linux
相关资讯       PL/SQL  获取MAC地址 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款