oracle 怎么 监控数据变化

2025-03-25 20:40:35
推荐回答(1个)
回答1:

实现:
1. 在plsqldev 中编译java代码 调用接口(具体的语法百度即可) 访问地址是:192.168.12.57:8088/Jfinaltest/show

[sql] view plain copy
create or replace and compile java source named jxdClient as

import java.net.*;

public class Demo {

public static void main(String[] args) {

try {
URL url = new URL("http://192.168.12.57:8088/Jfinaltest/show");
URLConnection rulConnection = url.openConnection();
rulConnection.connect();
rulConnection.getInputStream();
} catch (Exception e) {
e.printStackTrace();
}
}
}

2. 生成存储过程

[sql] view plain copy
create or replace procedure prc_hehe as language java name 'Demo.main(java.lang.String[])';

3. 编写触发器调用存储过程(pre_hehe)

[sql] view plain copy
create or replace trigger jxd7_trigger_wf_nodeinstance
after update or insert
on jxd7_wf_nodeinstance
for each row
begin
if inserting then
prc_hehe;
elsif updating then
prc_hehe;
elsif deleting then
prc_hehe;
end if;
end;

小结:每次表中的数据发生变化的时候,都会执行触发器中的存储过程,存储过程会调用程序的接口,之后程序处理业务逻辑。减少了代码量,保证了数据处理的实时性,减少了程序的压力