主要是学习PL/SQL调用JAVA的方法.平台:WINDOWS1.首先用PL/SQL创建好JAVA 源文件(JAVA source)并进行编译,直到没有错误.注意调用一些外部JAVA 包的时候,编译的时候可能不报错,直到你执行函数的时候才会错误,错误信息一般为:ORA-29540create 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!!!"};}
Oracle LOGMNR挖掘日志与DUMP日志对比Oracle 10g RAC监听报TNS-12545 TNS-12560 TNS-00515相关资讯 PL/SQL 获取MAC地址
- PL/SQL之存储过程和函数 (今 14:09)
- PL/SQL Developer连接本地Oracle (07月27日)
- 【PL/SQL系列】Oracle存储过程使用 (04月23日)
| - PL/SQL Developer 使用技巧分享 (09月16日)
- PL/SQL实现Java中的split()方法的 (07月10日)
- 从一个案例看PL/SQL代码片的编译与 (03月04日)
|
本文评论 查看全部评论 (0)