Hello. I have loaded jsch jar  to oracle 11g database and i have created the following package

CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED ODS_DWH.SFTP as

import com.jcraft.jsch.*;
import java.io.*;

public class Sftp {


private static final String KNOWN_HOSTS = "~/.ssh/known_hosts";

public static void main(){

}

public static String sftpcmd(String vUser, String vPass, String vHost, String vSrcFile, String vDstFile, String vCmd) {

JSch jsch = new JSch();

Session session = null;

ChannelSftp sftpChannel  = null;

        int iTimeOut  = 10000; // 10 second timeout

try {




session = jsch.getSession(vUser, vHost, 22);

session.setConfig("StrictHostKeyChecking","no");

session.setPassword(vPass);

session.connect(iTimeOut);

Channel channel = session.openChannel("sftp");

channel.connect(iTimeOut);

sftpChannel = (ChannelSftp) channel;

if (vCmd.equals("get")) {

sftpChannel.get(vSrcFile, vDstFile);

}

if (vCmd.equals("put")) {

sftpChannel.put(vSrcFile, vDstFile);

}

session.disconnect();

return("Ok");

} catch (JSchException e) {

return("JSchException Error : " + e.toString());

} catch (SftpException e) {

return("SftpException Error : " + e.toString());

} catch (Exception e) {

return("Exception Error : " + e.toString());

}  finally {

if ( sftpChannel != null && sftpChannel.isConnected()) {

sftpChannel.exit();

}

if ( session != null && session.isConnected()) {

session.disconnect();

}

}

}

}
/


------------------------------------------------------------------------------------------------------------------------

I then created a function

function sftp_cmd(  vUser varchar2, vPass varchar2, vHost varchar2, vSrcFile varchar2, vDestFile varchar2, vCmd varchar2 ) return varchar2

as language java name 'Sftp. sftpcmd( java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String ) return java.lang.String';


and i call it

vResult :=  sftp_cmd(  vUser => csftp_client_row.username, vPass => csftp_client_row.passwd, vHost =>  csftp_client_row.host_ip, vDestFile => vRemoteFileWithPath,  vSrcFile =>vLocalDirPath || '/' || vLocalFileName ,  vCmd => 'put' );


Then i get the following error       com.jcraft.jsch.JSchException: Packet corrupt

Any ideas? Thank for your time

Antonis