Ejemplo n.º 1
0
 public Link findLink(Long linkId) {
   SQLCommand cmd = new SQLCommand();
   RowSet rs = cmd.queryRowSet("select * from link where id=" + linkId);
   try {
     if (rs.next()) {
       return getLink(rs);
     } else {
       return null;
     }
   } catch (SQLException e) {
     e.printStackTrace();
     return null;
   }
 }
Ejemplo n.º 2
0
 public List<Link> listAllLink() {
   SQLCommand cmd = new SQLCommand();
   RowSet rs = cmd.queryRowSet("select * from link");
   List<Link> list = new ArrayList<Link>();
   Link link;
   try {
     while (rs.next()) {
       list.add(getLink(rs));
     }
     return list;
   } catch (SQLException e) {
     e.printStackTrace();
     return null;
   }
 }
Ejemplo n.º 3
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);
   }
 }
Ejemplo n.º 4
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);
   }
 }
Ejemplo n.º 5
0
 public boolean delLink(Long linkId) {
   SQLCommand cmd = new SQLCommand();
   return -1 != cmd.executeSQL("delete from link where id=" + linkId);
 }