@Override
 public boolean delete(int id) {
   try {
     Connection connection = PoolConnection.getConnection();
     try {
       connection.setAutoCommit(false);
       chtdao.deleteByCategoryId(connection, id);
       udao.deleteByCatID(connection, id);
       chpdao.deleteByCategoryId(connection, id);
       cdao.delete(connection, id);
       connection.commit();
     } catch (SQLTransactionException e) {
       connection.rollback();
       return false;
     } finally {
       if (connection != null) {
         connection.setAutoCommit(true);
         connection.close();
       }
     }
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return true;
 }
 public List<Category> getAllChosenCategories(int userId) {
   try (Connection connection = PoolConnection.getConnection()) {
     return udao.getAllChosen(connection, userId);
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return null;
 }
 public boolean insertIntoUserHasCategories(UserHasCategory usHas) {
   try {
     Connection connection = PoolConnection.getConnection();
     try {
       connection.setAutoCommit(false);
       udao.insert(connection, usHas.getCategoryID(), usHas.getUserId());
       connection.commit();
     } catch (SQLTransactionException e) {
       connection.rollback();
       return false;
     } finally {
       if (connection != null) {
         connection.setAutoCommit(true);
         connection.close();
       }
     }
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return true;
 }