public static boolean removeMapping(Item item, Category c) throws SQLException {
   final String sql =
       "delete from "
           + TABLE_NAME
           + " where "
           + ITEM_ID_FIELD_NAME
           + " = ? AND "
           + CATEGORY_ID_FIELD_NAME
           + " = ?;";
   final PreparedStatement st = DataManager.getCon().prepareStatement(sql);
   final int res;
   try {
     st.setLong(1, item.getID());
     st.setLong(2, c.getID());
     try {
       res = st.executeUpdate();
     } catch (MySQLIntegrityConstraintViolationException s) {
       return false;
     }
   } finally {
     try {
       if (st != null) {
         st.close();
       }
     } catch (final SQLException e) {
       System.out.println("Error closing prepared statement : " + e.getMessage());
     }
   }
   return res == 1;
 }
 public static boolean addMapping(Item item, Category c) throws SQLException {
   final String sql =
       "insert into "
           + TABLE_NAME
           + " ("
           + ITEM_ID_FIELD_NAME
           + ", "
           + CATEGORY_ID_FIELD_NAME
           + ") values (?, ?);";
   final PreparedStatement st =
       DataManager.getCon().prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
   st.setQueryTimeout(5);
   final int res;
   try {
     st.setLong(1, item.getID());
     st.setLong(2, c.getID());
     try {
       res = st.executeUpdate();
     } catch (MySQLIntegrityConstraintViolationException s) {
       return false;
     }
   } finally {
     try {
       if (st != null) {
         st.close();
       }
     } catch (final SQLException e) {
       System.out.println("Error closing prepared statement : " + e.getMessage());
     }
   }
   return res == 1;
 }
 public SparseIntArray buildCategoryIndex(ArrayList<Category> myCategoryList) {
   SparseIntArray myPositionMap = new SparseIntArray();
   Integer position = 0;
   for (Category myCat : myCategoryList) {
     myPositionMap.put(myCat.getID(), position);
     position++;
   }
   return myPositionMap;
 }