日期:2014-05-17  浏览次数:20639 次

每隔3秒调用一次存储过程
怎么每隔3秒调用一次存储过程呢?
代码怎么写呀?
public  boolean  getSendMessageRecipients()
{
Connection conn = null;
CallableStatement cs = null;
ResultSet rs = null;
boolean flag = true;
try
{
conn = DBControl.getConnection();
cs = conn.prepareCall("{call tb_sp_management_send_message(?,?,?)}");
    rs=cs.executeQuery();
} catch (Exception e)
{
logger.error("", e);
} finally
{
DbUtils.closeQuietly(conn, cs, rs);
}
return flag;
}

------解决方案--------------------


  public void functionname(){
    Timer timer;
    timer.schedule(new TimerTask() {
      public void run() {
        getSendMessageRecipients();
      }
    }
    , 0L, SMSINTERVAL * 1000);//这里的时间自己改
  }