public ArrayList<Item> searchProduct(String category, String title,
			String leadSinger, int quantity, ArrayList<Item> searchList)
			throws ConnectException, SQLException {

		searchList = new ArrayList<Item>();
		System.out.println("getItem");
		Item item = null;
		Connection con = ConnectionService.getConnection();
		String query = null;
		PreparedStatement query_ps = null;
		if (!(leadSinger.equals("") || null == leadSinger
				|| category.equals("") || null == category || title.equals("") || null == title)) {

			query = "SELECT item.upc,title,item_stock,item_category,item_price FROM"
					+ " item,leadsinger where item.upc=leadsinger.upc and "
					+ "item.item_category=? and item.title=? "
					+ "and leadsinger.singer_name=?";

			query_ps = con.prepareStatement(query);

			query_ps.setString(1, category);
			query_ps.setString(2, title);

			query_ps.setString(3, leadSinger);

		} else if (!(category.equals("") || null == category
				|| title.equals("") || null == title)) {

			query = "SELECT item.upc,title,item_stock,item_category,item_price "
					+ "FROM item where item.title=? " + "and item_category=?";

			query_ps = con.prepareStatement(query);

			query_ps.setString(1, title);
			query_ps.setString(2, category);
		} else if (!(leadSinger.equals("") || null == leadSinger
				|| title.equals("") || null == title)) {

			query = "SELECT item.upc,title,item_stock,item_category,item_price FROM "
					+ "item,leadsinger where item.upc=leadsinger.upc "
					+ "and item.title=? " + "and leadsinger.singer_name=?";

			query_ps = con.prepareStatement(query);

			query_ps.setString(1, title);
			query_ps.setString(2, leadSinger);
		} else if (!(leadSinger.equals("") || null == leadSinger
				|| category.equals("") || null == category)) {

			query = "SELECT item.upc,title,item_stock,item_category,item_price"
					+ " FROM item,leadsinger where item.upc=leadsinger.upc "
					+ "and item.item_category=?"
					+ " and leadsinger.singer_name=?";

			query_ps = con.prepareStatement(query);

			query_ps.setString(1, category);
			query_ps.setString(2, leadSinger);
		}
		else if (!(category.equals("") || null == category)) {
			query = "SELECT item.upc,title,item_stock,item_category,item_price "
					+ "FROM item where item_category=?";
			query_ps = con.prepareStatement(query);
			query_ps.setString(1, category);
		}
		else if (!(title.equals("") || null == title)) {
			query = "SELECT item.upc,title,item_stock,item_category,item_price "
					+ "FROM item where item.title=?";
			query_ps = con.prepareStatement(query);

			query_ps.setString(1, title);

		}
		else if (!(leadSinger.equals("") || null == leadSinger)) {
			query = "SELECT item.upc,title,item_stock,item_category,item_price FROM item,leadsinger "
					+ "where item.upc=leadsinger.upc and leadsinger.singer_name=?";
			query_ps = con.prepareStatement(query);

			query_ps.setString(1, leadSinger);

		}

		ResultSet rs = query_ps.executeQuery();
		if (rs != null) {
			while (rs.next()) {

				item = new Item();
				item.setPrice(rs.getFloat(5));
				item.setCategory(rs.getString(4));
				item.setQuantity(rs.getInt(3));
				item.setTitle(rs.getString(2));
				item.setUPC(Integer.toString(rs.getInt(1)));
				if (item.getQuantity() < quantity) {
					item.setErrorMessage("Requested Quantity Not Available. Quantity set to Available stock");
					item.setQuantity(item.getQuantity());
				} else {
					item.setQuantity(quantity);
				}
				if (item.getQuantity() != 0)
					searchList.add(item);
			}

		}

		con.commit();
		return searchList;

	}