I have written code which does the following:The main goal is to fetch emails from inbox and spam folders and store them in a database. It fetches emails from Gmail, GMX, web.de, Yahoo and Hotmail.The following attributes are stored in a MySQL database:Slno, messagedigest, messageid, foldername, dateandtime, receiver, sender, subject, cc, size and emlfile.For Gmail, GMY and web.de, I have used the JavaMail API because email from it can be fetched with IMAP.For Yahoo and Hotmail, I have used an HTML parser and HTTP client to fetch emails from the spam folder, and for the inbox folder, I have used the POP3 JavaMail API.I want to have a proper class hierarchy which makes my code efficient and easily reusable. I am sure it can still be improved, so I would like to have different opinions on it.I have the following classes and methods as of now:MainController - Here I pass emailid, password and foldername from which emails have to be fetched.Abstract class - EmailProtocolAbstract methods of it (all methods except executeParser contains method definition):connectImap() - used by GMX, Gmail and web.de email IDsconnectPop3() - used by Hotmail and Yahoo to fetch emails from the inbox foldercreateMessageDigest - used by every email provider (GMX, Gmail, web.de, Yahoo, and Hotmail)establishDBConnection - used by every emailemailAlreadyExists // used by every email which checks whether email already exists in db or not, if not then store it.storeemailproperties - used by every email to store emails properties to MySQL databaseexecuteParser - nothing written in it. Overridden and used by just Hotmail and Yahoo to fetch emails from the spam folder.Imap extends EmailProtocolThere's nothing in it, but I have to have it to access methods of EmailProtocol. This is used to fetch emails from Gmail, GMX and web.de. I know this is really a bad way but don't know how to do it another way.Hotmail extends EmailProtocolMethods:executeParser() - This is used by just a Hotmail email ID.fetchjunkemails() - This is also very specific for only a Hotmail email ID.Yahoo extends EmailProtocolMethods:executeParser()storeEmailtotemptable()MoveEmailtoInbox()getFoldername()nullorEquals()All above methods are specific for a Yahoo email ID.public DateTimeFormat(class)format() - This formats datetime of GMAX, Gmail and web.de emails.formatYahoodate - This formats datetime of Yahoo email.formatHotmaildate - This formats datetime of a Hotmail email.public StringFormatConvertStreamToString() - Accessed by every class except the DateTimeFormat class.formatFromTo() - Accessed by every class except the DateTimeFormat class. public Class CheckDatabaseExistancepublic static void checkForDatabaseTablesAvailability()(This method checks at the beginning whether the database and required tables exist in MySQL or not. If not, it creates them.)Please see my MainController class so that you can have an idea about how I use different classes.public class MainController {    public static void main(String[] args) throws Exception {        ArrayList<String> web_de_folders = new ArrayList<String>();        web_de_folders.add(INBOX);        web_de_folders.add(Unbekannt);        web_de_folders.add(Spam);        web_de_folders.add(OUTBOX);        web_de_folders.add(SENT);        web_de_folders.add(DRAFTS);        web_de_folders.add(TRASH);        web_de_folders.add(Trash);ArrayList<String> gmx_folders = new ArrayList<String>();        gmx_folders.add(INBOX);        gmx_folders.add(Archiv);        gmx_folders.add(Entwrfe);        gmx_folders.add(Gelscht);        gmx_folders.add(Gesendet);        gmx_folders.add(Spamverdacht);        gmx_folders.add(Trash);        ArrayList<String> gmail_folders = new ArrayList<String>();        gmail_folders.add(Inbox);        gmail_folders.add([Google Mail]/Spam);        gmail_folders.add([Google Mail]/Trash);        gmail_folders.add([Google Mail]/Sent Mail);        ArrayList<String> pop3_folders = new ArrayList<String>();        pop3_folders.add(INBOX);        CheckDatabaseExistance.checkForDatabaseTablesAvailability();        EmailProtocol imap = new Imap();        System.out.println(CHECKING FOR NEW EMAILS IN WEB.DE...(IMAP));        System.out.println(*********************************************************************************);        imap.connectImap(email@web.de, pwd, web_de_folders);        System.out.println(\nCHECKING FOR NEW EMAILS IN GMX.DE...(IMAP));        System.out.println(*********************************************************************************);        imap.connectImap(email@gmx.de, pwd, gmx_folders);        System.out.println(\nCHECKING FOR NEW EMAILS IN GMAIL...(IMAP));        System.out.println(*********************************************************************************);        imap.connectImap(email@gmail.com, pwd, gmail_folders);         EmailProtocol yahoo = new Yahoo();        Yahoo y=new Yahoo();        System.out.println(\nEXECUTING YAHOO PARSER);        System.out.println(*********************************************************************************);        y.executeParser(http://de.mc1321.mail.yahoo.com/mc/welcome?ymv=0,email@yahoo.de,pwd);        System.out.println(\nCHECKING FOR NEW EMAILS IN INBOX OF YAHOO (POP3));        System.out.println(*********************************************************************************);        yahoo.connectPop3(email@yahoo.de,pwd,pop3_folders);         System.out.println(\nCHECKING FOR NEW EMAILS IN INBOX OF HOTMAIL (POP3));        System.out.println(*********************************************************************************);        yahoo.connectPop3(email@hotmail.com,pwd,pop3_folders);        EmailProtocol hotmail = new Hotmail();        Hotmail h=new Hotmail();        System.out.println(\nEXECUTING HOTMAIL PARSER);        System.out.println(*********************************************************************************);        h.executeParser(https://login.live.com/ppsecure/post.srf,email@hotmail.com,pwd);     }}I have kept the DatetimeFormat and StringFormat classes public so that I can access their public methods by just DatetimeFormat.formatYahoodate for e.g. from different methods.
Fetching emails from various clients to store in a database
java;beginner;email