从 dba_change_notification_reg中拿ip对比本机ip
2016-09-28 14:39
253 查看
try {
conn = db.getConnection();
//撤销注册
String sql = "select * from dba_change_notification_regs";
Statement statement = conn.createStatement();
rs = statement.executeQuery(sql);
List<String> listCallBack = new ArrayList<String>();
List list = new ArrayList();//用来存放最后无重复项的数据
HashSet h ;//用来去除重复项
InetAddress addr=InetAddress.getLocalHost();//获取本机ip
String localIp=addr.getHostAddress();//获取本机ip
while(rs.next()){
String s = rs.getString("CALLBACK");
String s2 = s.substring(s.indexOf("HOST=")+5, s.indexOf(")(PORT="));
listCallBack.add(s2);
h = new HashSet(listCallBack);
list.clear();//清除
list.addAll(h);//去除重复项
}
if(!list.contains(localIp)){//如果未注册过再注册
//dcr = ((OracleConnection) conn).registerDatabaseChangeNotification(prop);
System.out.println("------------------------没注册过");
}
System.out.println("------------------------注册过");
//删除以前注册过的监听
logger.info("---------localIp-----开始----------");
InetAddress addr=InetAddress.getLocalHost();//获取本机ip
String localIp=addr.getHostAddress();//获取本机ip
logger.info("---------localIp---------------"+localIp);
//撤销本机的注册记录
String sql = "select distinct regid from dba_change_notification_regs where CALLBACK like '%"+localIp+"%'";
statement = conn.createStatement();
rs = statement.executeQuery(sql);
List<Integer> regIds = new ArrayList();
while(rs.next()){
regIds.add((Integer)rs.getInt("regid"));
}
if(regIds!=null){//如果本机注册过就删除掉,注意只删除本地机注册的
for(Integer i:regIds){
((OracleConnection) conn).unregisterDatabaseChangeNotification(i);
}
}
conn = db.getConnection();
//撤销注册
String sql = "select * from dba_change_notification_regs";
Statement statement = conn.createStatement();
rs = statement.executeQuery(sql);
List<String> listCallBack = new ArrayList<String>();
List list = new ArrayList();//用来存放最后无重复项的数据
HashSet h ;//用来去除重复项
InetAddress addr=InetAddress.getLocalHost();//获取本机ip
String localIp=addr.getHostAddress();//获取本机ip
while(rs.next()){
String s = rs.getString("CALLBACK");
String s2 = s.substring(s.indexOf("HOST=")+5, s.indexOf(")(PORT="));
listCallBack.add(s2);
h = new HashSet(listCallBack);
list.clear();//清除
list.addAll(h);//去除重复项
}
if(!list.contains(localIp)){//如果未注册过再注册
//dcr = ((OracleConnection) conn).registerDatabaseChangeNotification(prop);
System.out.println("------------------------没注册过");
}
System.out.println("------------------------注册过");
//删除以前注册过的监听
logger.info("---------localIp-----开始----------");
InetAddress addr=InetAddress.getLocalHost();//获取本机ip
String localIp=addr.getHostAddress();//获取本机ip
logger.info("---------localIp---------------"+localIp);
//撤销本机的注册记录
String sql = "select distinct regid from dba_change_notification_regs where CALLBACK like '%"+localIp+"%'";
statement = conn.createStatement();
rs = statement.executeQuery(sql);
List<Integer> regIds = new ArrayList();
while(rs.next()){
regIds.add((Integer)rs.getInt("regid"));
}
if(regIds!=null){//如果本机注册过就删除掉,注意只删除本地机注册的
for(Integer i:regIds){
((OracleConnection) conn).unregisterDatabaseChangeNotification(i);
}
}
相关文章推荐
- step by step change public-ip and vip
- IP Address change and Symbian Access Point Reconnection Issues
- 通过RegOpenKeyEx和RegQueryValueEx获取wince设备的IP
- step by step change public-ip and vip
- FindFirstChangeNotification FindNextChangeNotification实现应用层文件监控的代码分析
- Database Change Notification(数据库变化通知)
- 外部IP的Windows通知服务(External IP Windows Notification Service)
- RegNotifyChangeKeyValue 监听注册表
- PHP获取IP的方法对比
- How to change the network IP addresses of SQL Server failover cluster instances-[From MS]
- (转)FindFirstChangeNotification,创建一个文件通知对象,该对象用于监视文件系统发生的变化
- FindFirstChangeNotification
- 如何修改OracleRAC虚IP(Update/Change Virtual IP)
- JAVA结合Oracle的Database Change Notification实现替代获取实时数据需要的刷库操作
- experiment: File Change Notification
- OSI七层协议和TCP/IP四层协议对比
- Notification通知,通知中心,发布通知,通知代理对比 - iOS
- Change the default Phone ringtone and notification ringtone
- 监控目录中文件的变化---FindFirstChangeNotification
- 用RegNotifyChangeKeyValue() 设置与注册表项长期关联