java定时器和实时查询数据库

定时器:

  Timer timer = new Timer();
                    timer.schedule(new TimerTask() {
                        public void run() {
                          // 逻辑代码
                        }
                    }, 3600000);//一小时

 

实时查询:

  $(document).ready(function() {
         hello();
     });

  function hello(){
         $.ajax({
                url:"http://xxx.com/a/xx",
                type:"post",
                data:{sjl:1},
                dataType:"json",
                success:function(data){
                  var str = "";
                       for(var i = 0; i < data.length; i++){
                         str += "

";
                         str += "
    ";
                             str += "
  • ";
                             str += "
    ";
                             str += "";
                             str += ""+data[i]+"";
                             str += "
    " + "
  • " + "
" + "
";
                       }
                  $("#cid").html(str);
                },
         })

  }

 

转载于:https://www.cnblogs.com/3b2414/p/9319306.html

你可能感兴趣的:(java定时器和实时查询数据库)