Beispiel #1
0
 private Link getLink(RowSet rs) throws SQLException {
   Link link = new Link();
   link.setLId(rs.getLong("id"));
   link.setLName(rs.getString("name"));
   link.setLUrl(rs.getString("url"));
   link.setLImg(rs.getString("img"));
   link.setLInfo(rs.getString("info"));
   link.setLIsLock(rs.getBoolean("is_lock"));
   link.setLAddtime(rs.getDate("add_time"));
   return link;
 }
Beispiel #2
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);
   }
 }
Beispiel #3
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);
   }
 }