All pastes #513708 Raw Edit

Something

public text v1 · immutable
#513708 ·published 2007-05-27 11:33 UTC
rendered paste body
/**
	 * Get the id of the location name given in the parameter. On success return
	 * the id, on failure return 0
	 * 
	 * @param 	name	the location name
	 * @return	location id
	 */
	public int getLocationIdByName(String name) {
		String sql = "SELECT a.commentid FROM " + getTagTable() + " a INNER JOIN " + getComTable() + " b ON a.commentid = b.id WHERE b.topic = '" + name + "'";
		
		try {
			ResultSet rs = select(sql);
			if(! rs.next()) return 0;
			int lid = rs.getInt("commentid");
			rs.close();
			
			return lid;
		} catch (SQLException e) {
			e.printStackTrace();
			
			return 0;
		}
	}