时间跳转和自增

来源:互联网 发布:网络拓扑发现开源软件 编辑:程序博客网 时间:2024/05/06 06:54

时间跳转:

<span id="time" style="background:red">5</span>秒钟后自动跳转,如果不跳转,请点击下面链接

<script language="JavaScript1.2" type="text/javascript">
<!--
//  Place this in the 'head' section of your page. 

function delayURL(url) {
 var delay = document.getElementById("time").innerHTML;
//alert(delay);
 if(delay > 0) {
  delay--;
  document.getElementById("time").innerHTML = delay;
 } else {
  window.top.location.href = url;
    }
    setTimeout("delayURL('" + url + "')", 1000); //delayURL(http://wwer)
}

 

自增id:

Connection conn = DB.getConn();

  boolean autoCommit = conn.getAutoCommit();
  conn.setAutoCommit(false);
  
  int rootId = -1;
  
  String sql = "insert into article values (null, ?, ?, ?, ?, now(), ?)";
  PreparedStatement pstmt = DB.prepareStmt(conn, sql, Statement.RETURN_GENERATED_KEYS);
  pstmt.setInt(1, 0);
  pstmt.setInt(2, rootId);
  pstmt.setString(3, title);
  pstmt.setString(4, cont);
  pstmt.setInt(5, 0);
  pstmt.executeUpdate();
  
  ResultSet rsKey = pstmt.getGeneratedKeys();
  rsKey.next();
  rootId = rsKey.getInt(1);
 
  Statement stmt = DB.createStmt(conn);
  stmt.executeUpdate("update article set rootid = " + rootId + " where id = " + rootId);

  conn.commit();
  conn.setAutoCommit(autoCommit);
  DB.close(pstmt);
  DB.close(stmt);
  DB.close(conn);

原创粉丝点击