用java实现实时扫描数据库(例如:隔1秒扫描ACCESS数据库表)急:谢谢

yan_tao_168_ 2006-08-30 09:55:35
用java实现实时扫描数据库(例如:隔1秒扫描ACCESS数据库表)
能举个小例子更好再次谢谢
...全文
852 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
w_yuxiang 2007-03-15
  • 打赏
  • 举报
回复
up
ccht_man 2007-03-14
  • 打赏
  • 举报
回复
用后台线程怎么写啊???
wuyg719 2006-09-07
  • 打赏
  • 举报
回复
这个其实用监听模式比较好,如果真要扫描,用后台线程即可
yan_tao_168_ 2006-09-04
  • 打赏
  • 举报
回复
请问高手我想做成一个后台的监听程序,怎么样实现呢?能给出资料,方法或是代码,再一次拜谢了最好能说的详细点。
winnyboy 2006-09-02
  • 打赏
  • 举报
回复
package com.barcode;

import java.util.*;

/**
* <p>Title: </p>
* <p>Description: 将未发送及发送不成功的二维码压入管道</p>
* <p>Copyright: Copyright (c) 2006-1-7</p>
* <p>Company: 新宇龙信息技术有限公司</p>
* @author 增值事业部--贺建科
* @version 1.0
*/

public class PushNewBarcodeToPool
extends Engine {
//用于计数,是否到了给PUSH已发送但未取票的用户再次发送
public static int min = 0;
String sql = "";
//String sql = "select * from tom_ticket_order";
DbConnect db;
public PushNewBarcodeToPool() {
super("PushNewBarcodeToPool");
setDaemon(true);
db = new DbConnect();
}

public void run() {
while (true) {
Vector vResult = new Vector();
//获得需要发送二维码的用户 判断是否为PUSH已发送未取票需再次发送或是PUSH需要发送的
if(min ==0 || min == 360) {
sql = "select a.order_id, a.ticket_id, a.phone_no, a.order_name, a.order_time, a.ticket_counts, a.email, a.user_no, b.hold_no, b.area_code,b.ticket_no, b.eff_time, b.exp_time, b.barcode_name, b.barcode_addr, a.send_flag,b.company_no from tom_ticket_order a, tbc_ticket_info b where a.status='Q0A' and (a.send_flag not like 'Q0S%') and a.send_times<1 and a.ticket_id=b.ticket_id";
if(min == 360)
min= 0;
}else {
sql = "select a.order_id, a.ticket_id, a.phone_no, a.order_name, a.order_time, a.ticket_counts, a.email, a.user_no, b.hold_no, b.area_code,b.ticket_no, b.eff_time, b.exp_time, b.barcode_name, b.barcode_addr, a.send_flag,b.company_no from tom_ticket_order a, tbc_ticket_info b where a.status='Q0A' and (a.send_flag not like 'Q0S%' and a.send_flag not like 'Q0M%') and a.send_times<1 and a.ticket_id=b.ticket_id";
}
vResult = (Vector) db.executeSQL(sql);
int size = vResult.size();
//如果有需要发送二维码的用户
if (size > 0) {

System.out.println("[" + Log.getDateString() + " " +
Log.getTimeString() + "] 发现有" + size +
"个电子票待发");
DataPool.LogPool.push("[" + Log.getDateString() + " " +
Log.getTimeString() + "] 发现有" + size +
"个电子票待发");
for (int i = 0; i < size; i++) {
if (DataPool.PushPool.getSize() < 300) {
//将需要发送二维码的用户放入发送管道
DataPool.PushPool.push( (Barcode) vResult.get(i));
System.out.println("[" + Log.getDateString() + " " +
Log.getTimeString() + "] 订单号为" +
( (Barcode) vResult.get(i)).
getOrder_id() +
"进入发送管道"
);
}
}
}
//所以用户都放入发送管道之后,清空结果对象
vResult.removeAllElements();
try {
min ++;
//睡眠一分钟
sleep(TimeConfig.TIME_ONE_MINUTE);
}
catch (Exception e) {
e.printStackTrace();
}
}
}
}
wendi 2006-08-31
  • 打赏
  • 举报
回复
写个线程撒。

256

社区成员

发帖
与我相关
我的任务
社区描述
其他产品/厂家
社区管理员
  • 其他
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧