/** * Search an id by providing the topic string, returning the id if topic name exists * or 0 on a no db match. * * @param name topic title * @return the id of the comment */ protected int getCommentIdByTopic(String name) { String sql = "SELECT a.id FROM " + getComTable() + " a INNER JOIN " + getTagTable() + " b ON a.id = b.commentid WHERE a.topic = '" + name + "' AND b.sectionid = '" + getSectionId() + "'"; try { ResultSet rs = select(sql); if(! rs.next()) return 0; int cid = rs.getInt("id"); rs.close(); return cid; } catch (SQLException e) { e.printStackTrace(); return 0; } }