I need to check the health of the SFTP connection using JSch liberary. I have used the following approach. Please correct me if I am wrong.
public boolean checkConnection() throws JSchException {
try {
JSch jsch = new JSch();
Session session = sch.getSession(username, host);
session.setPort(PORT);
session.setPassword(password);
session.connect();
return true;
} catch(Exception ex){
LOG.error("Error while connecting to SFTP", ex);
}
return false
}