I get data from the MySQL
database where it contain names of products. I have two databases. One which contains Local Products while other database carry foreign products. I need to get data from both the databases.
In order to success I use the JDBC
connection and retreive data and put into two arraylists
. As I want to ignore duplicates I use a hashset
. I fed in those arraylist
to hashset
and then get back the arraylist
again which do not contains duplicates.
I know that HashSet
has no sorting way so it changes over the time. I do not want that to happen. I want to keep that read in data order as it is after removing duplicates also.
Sample Code I use:
localProductHashSet.addAll(getLocalProduct);
getLocalProduct.clear();
getLocalProduct.addAll(localProductHashSet);
Collections.sort(getLocalProduct);