title: Using connection pool with JSCH
body: <p>I'm using JSCH for file upload ever sftp. In it's current state each thread opens and closes connection when needed. </p>
  
  <p>If it possible to use connection pooling with JSCH in order to avoid overhead caused by large number of connection opening and closing?</p>
  
  <p>Here is a example of function called from inside of thread</p>
  
  <pre><code> public static void file_upload(String filename) throws IOException {
      JSch jsch = new JSch();
      Session session = null;
      try {
          session = jsch.getSession("user", "server_name", 22);
          session.setConfig("StrictHostKeyChecking", "no");
          session.setPassword("super_secre_password");
          session.connect();
  
          Channel channel = session.openChannel("sftp");
          channel.connect();
          ChannelSftp sftpChannel = (ChannelSftp) channel;
  
          FileInputStream inputSrr = new FileInputStream(filename);  
          try {  
              sftpChannel.put(inputSrr, "/var/temp/"+filename);  
          } catch (SftpException e) {  
              e.printStackTrace();  
  
          } finally {  
              if (inputSrr != null) {  
                  inputSrr.close();  
              }  
          }  
  
          sftpChannel.exit();
          session.disconnect();
      } catch (JSchException e) {
          e.printStackTrace();
      } catch (SftpException e) {
          e.printStackTrace();
      }
  }
  </code></pre>