Esempio n. 1
0
 public boolean updateLink(Link link) {
   Connection conn = ConnectionFactory.getConnection();
   PreparedStatement pstmt = null;
   String sql = "	UPDATE link SET url=?, name=?, img=?, info=?, is_lock=? WHERE id=?";
   try {
     pstmt = conn.prepareStatement(sql);
     pstmt.setString(1, link.getLUrl());
     pstmt.setString(2, link.getLName());
     pstmt.setString(3, link.getLImg());
     pstmt.setString(4, link.getLInfo());
     pstmt.setBoolean(5, link.getLIsLock());
     pstmt.setLong(6, link.getLId());
     //	pstmt.setDate(6, new java.sql.Date(link.getLAddtime().getTime()));
     return 1 == pstmt.executeUpdate();
   } catch (SQLException e) {
     e.printStackTrace();
     return false;
   } finally {
     SQLCommand.close(pstmt);
     SQLCommand.close(conn);
   }
 }
Esempio n. 2
0
 public boolean addLink(Link link) {
   Connection conn = ConnectionFactory.getConnection();
   PreparedStatement pstmt = null;
   String sql =
       "INSERT INTO link(url, name, img, info, is_lock, add_time) VALUES( ?, ?, ?, ?, ?, ?)";
   try {
     pstmt = conn.prepareStatement(sql);
     // pstmt.setLong(1, survey.getTemplet());
     pstmt.setString(1, link.getLUrl());
     pstmt.setString(2, link.getLName());
     pstmt.setString(3, link.getLImg());
     pstmt.setString(4, link.getLInfo());
     pstmt.setBoolean(5, link.getLIsLock());
     pstmt.setDate(6, new java.sql.Date(link.getLAddtime().getTime()));
     return 1 == pstmt.executeUpdate();
   } catch (SQLException e) {
     e.printStackTrace();
     return false;
   } finally {
     SQLCommand.close(pstmt);
     SQLCommand.close(conn);
   }
 }