public void exce(int type, Server server, String fromLocalDir, String toServerDir) { SSHExec sshExec = null; try { SSHExec.setOption(IOptionName.HALT_ON_FAILURE, true); sshExec = ConnectionPoolManager.getInstance().getConnection(server.getServerIp()); if (type == CommanConstant.STATE_UPLOAD_SINGLE) { sshExec.uploadSingleDataToServer(fromLocalDir, toServerDir); } else { sshExec.uploadAllDataToServer(fromLocalDir, toServerDir); } } catch (TaskExecFailException e) { System.out.println(e.getMessage()); e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { ConnectionPoolManager.getInstance().close(server.getServerIp(), sshExec); } }