title: How to perform multiple operations with JSch
body: <p>I am new to SSH and JSch. When I connect from my client to the server I want to do two tasks:</p>
  
  <ol>
  <li>Upload a file (using <code>ChannelSFTP</code>)</li>
  <li>Perform commands, like creating a directory, and searching through a MySQL database</li>
  </ol>
  
  <p>At the moment I am using two separate shell logins to perform each task (actually I haven't started programming the MySQL queries yet).</p>
  
  <p>For the upload the relevant code is </p>
  
  <pre><code>session.connect();
  
  Channel channel=session.openChannel("sftp");
  channel.connect();
  ChannelSftp c=(ChannelSftp)channel;
  c.put(source, destination);
  </code></pre>
  
  <p>And for the command I have</p>
  
  <pre><code>String command = "ls -l";//just an example 
  Channel channel=session.openChannel("exec");
  ((ChannelExec)channel).setCommand(command);
  </code></pre>
  
  <p>Should I disconnect the session after the first channel and then open the second channel? Or close the session entirely and open a new session? As I said, I'm new to this.</p>