I have a desktop application that runs every 10 mins. I ask for login credentials at the beginning and then it carries on till the user exits the application.
I have my logic in such a way that if he enters correct credentials then the table is created and his login information is stored. If he enters wrong credentials then the table storing wrong credentials would be deleted and a pop up with invalid login pops up.
But when the user's system goes to a stand by or hibernate or if there is no internet connection, so basically if the application is unable to connect to the mail then it goes into the table deletion part and drops the table.
How can i handle this? If there is an internet interruption i want that if the user had previously successfully logged in then it should not drop the table rather exit.
Here is the code - After the login table is created and record inserted (immaterial it is authentic or not) the control comes over here -
public void run(){
Properties props = System.getProperties();
props.setProperty("mail.store.protocol", "imap");
try{
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imap");
store.connect(getMailboxId(), getEmailId(), getPassword());
inbox = store.getFolder("Inbox");
<<some data processing>>
}
catch (NoSuchProviderException e){
e.printStackTrace();
System.exit(1);
}
catch (MessagingException e){
try {
new DbConnect().deleteRecords(); //Delete table if invalid credentials
} catch (ClassNotFoundException d) {
d.printStackTrace();
}
e.printStackTrace();
JOptionPane.showMessageDialog(controllingFrame,
"Invalid Credentials. Try again.",
"Error Message",
JOptionPane.ERROR_MESSAGE);
System.exit(2);
}