FTP Connection Through JAVA

I am writing a java code to transfer a file from local machine to a server on another machine.
While uploading i am encountering with an exception which is showing as
java.net.ConnectException: Connection refused: connect
The file is getting transferred sucessfully if i am transferring it through command prompt instead of java code.
Please help me out.

Duplicated here
http://forum.java.sun.com/thread.jspa?threadID=700335&messageID=4063726#4063726
and here
http://forum.java.sun.com/thread.jspa?threadID=700257&messageID=4063471#4063471

Similar Messages

  • Ftp connection using java

    Hi All,
    I need to upload a file through ftp connection uisng java calss. any one know please reply me
    Thanks
    K.Kalikumar

    Hi Kali,
    I have worked on similar issues sending you the code.. hope it should work. I had written a TelnetInterface class where I did all operation inside the constructor.
    import javax.servlet.http.HttpSession;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.InputStream;
    import java.io.PrintStream;
    import org.apache.commons.net.telnet.TelnetClient;
    public class TelnetInterface {
         private TelnetClient telnet = new TelnetClient();
         private InputStream in;
         private PrintStream out;
         private String prompt = ">";
         private boolean isConnected ;
    public TelnetInterface(){
         public TelnetInterface(HttpServletRequest request) {
                   HttpSession session = request.getSession();
                   PropertyReader propReader = (PropertyReader)session.getAttribute("propReader");
                   String host=null,user=null,password=null,port=null;
                   int unixPort= 0;
    //                Get Unix credentials
                   if(propReader != null){
                        host=(String)propReader.getProperty("UNIX_HOST");
                        user=(String)propReader.getProperty("UNIX_UNAME");
                        password=(String)propReader.getProperty("UNIX_PWD");
                        port=(String)propReader.getProperty("UNIX_PORT");
                        unixPort = Integer.parseInt(port) ;
    //                    Connect to the specified server
                   System.out.println("Inside telnet Interface");
                   try{
                        telnet.connect(host, unixPort);
                        isConnected = true;
                        in = telnet.getInputStream();
                        out = new PrintStream(telnet.getOutputStream());
    //                    Log the user on
                        readUntil("login: ");
                        write(user);
                        System.out.println("user:"+ user);
                        readUntil("Password: ");
                        write(password);
                        System.out.println("password:"+ password);
                        sendCommand("su - loginuser");
                        su(" password");
                   }catch (IOException e) {
                        e.printStackTrace();
                        isConnected = false;     
                   }catch (Exception e){
                        e.printStackTrace();
         }

  • Problem with socket connection through Java Embedding...

    We are trying to create a simple socket connection to a socket server through BPEL PM using the Java Embedding component.
    BPEL Process : Client makes an asynchronous request. Passes an input variable. The input variable is sent to the Server Program through a socket connection through the Java embedding component.
    Server: We are running a simple Socket Server program from command prompt.
    The code below works fine as long as we do not try to receive a response from the server (Commented Code).
    If we uncomment the code and try to receive a response, it refuses to create an instance for the BPEL Process. And sometimes restarts the BPEL Server.
    Client Code:
    String msg="NONE";
    try{
    org.w3c.dom.Element input = (org.w3c.dom.Element) getVariableData("inputVariable","payload","/client:clientProcessRequest/client:input");
    msg = input.getNodeValue();
    Socket clientsoc=new Socket("ServerIP",1000);
    PrintWriter out1=new PrintWriter(clientsoc.getOutputStream());
    out1.write(msg);
    out1.flush();
    BufferedReader cin1=new BufferedReader(new InputStreamReader(clientsoc.getInputStream()));
    msg=cin1.readLine();
    setVariableData("outputVariable","payload","/client:result",new String(msg));
    clientsoc.close();
    catch(UnknownHostException e)
    System.err.println("Don't know about host: dev.");
    System.exit(1);
    catch (IOException e)
    System.err.println("Couldn't get I/O for "+ "the connection to: dev.");
    System.exit(1);
    }

    Repost

  • How do I get SQL Agent to perform an FTP connection through a SSIS package?

    I have created a number of SSIS packages that I am running through SQL Agent in various jobs.  I have set up a Credential / Proxy for the job steps and for the most part everything runs no problem.  The issue I have is with the step where I make
    a connection to a FTP server and download files.  In BIDS the step works fine but in SQL Agent the step times out.  I presume that it has to do with the account that it is being run under but that is what I thought the Credential / Proxy was supposed
    to handle (as it does for all the other steps).  I am running on SQL Server 2008 R2.  I have created a test job that has only one step which is to connect to the FTP server and download some text files.  I have tried utilizing package configuration
    files and have tried various ProtectionLevels to no avail.
    Anyone have any thoughts or direction for me to take?  Will continue to research and will post if I resolve this.
    Thanks, Andrew

    On the dev environment the ProtectionLevel is set to EncryptSensitiveWithUserKey and that is what I tried first on the prod server.  Subsequently I also tried utilizing a package config file (with ProtectionLevel then of DontSaveSensitive) and have
    also tried working with the ServerStorage.
    For deployment I copied the relevant dtsx files to a solution on the prod server.  I verified that the packages all had tested connections in the Connection Manager.  I have run all the packages in the BIDS on the prod server and they all worked. 
    I have created a test package from scratch on the prod server to test the ftp connection.  This test package runs from BIDS fine.  I have set the SQL Agent file to access through the file system (no luck) and have saved the package to the SSIS Packages
    and had the job step access from there (no luck either).

  • Background scheduling of FTP Connection through R/3

    Hello Friends,
      I have done FTP connection by using Z-pgm which uses function FTP_CONNECT. This is working fine in Foreground mode. 
    But in background scheduling of the z-pgm, i am getting the <b>error as 'RFC to program SAPFTP failed'.</b>
    I checked RFC destination SAPFTP in SM59. There Activation type is 'Start on Front End Work Station'. I tested the connection also. Its alright.
    How to do FTP processing in Background?
    Cheers,
    Seema

    Hello,
    you could try to use RFC destination 'SAPFTPA' - it's ftp on the application server. Since SAPFTP is  'Start on Front End Work Station' and in background there is no front end work station, it can't work.
    Regards Wolfgang

  • Connecting through java to HSQLDB: Out of Memory

    Through my java program i am connecting to hsqldb which has .data file of approx 6.5 GB and getting the error java.sql.SqlException: out of memory (am not getting anything else)
    have increased jvm option -Xms256m -Xmx1024m -XX:PermSize=64M -XX:MaxPermSize=2000M
    What else can be tried...??? A complete Stacktrace for the same
    exception in thread HSQL timer
    java.lang.OutofMemoryError: Java Heap Space
    Besides that also got this on netbeans console but seems this is something else... and not an error
    Mar 19, 2009 4:55:36 AM sun.awt.X11.XToolkit processException
    WARNING: Exception on Toolkit thread
    java.lang.OutOfMemoryError: Java heap space
    Edited by: shubham on Mar 19, 2009 1:57 AM
    Edited by: shubham on Mar 19, 2009 3:31 AM

    Well The issue was somewhere else due to it reading too much of data. It ran but my program is very slow (approx 2-3 hrs).
    I am worried about the speed...
    is it because of the large amount of data.. 23,355,459 records..?? or there could be some issue in programming probably memory leak etc..??
    -> reads db
    -> for each record set
    -> perform different operation/ writes to file

  • RFC connectivity through JAVA

    Hello sir,
    I have create 1 java class file which connects to SAP DB through RFC connection.
    I have put sapjco3.dll,librfc32.dll,sapjcorfc.dll in to the folder windows\system32.
    Its working fine on windowsXP, but not working on Windows Vista and windows server 2003.
    its giving error as
    java.lang.UnsatisfiedLinkError: D:\splerp3\sapjco3.dll: The application has failed to start because
    its side-by-side configuration is incorrect.
    please tell me what configuration i have to do for vista and server 2003.

    Hi guys,
    please pay attention to the given infos on the JCo download site. It says:
    Note: Starting with JCo 2.1.4 and JCo 2.0.11, JCo requires the Visual Studio .NET C/C++ runtime libraries on Windows platforms.
    Starting with JCo 3.0.0, it requires the Visual Studio 2005 C/C++ runtime libraries. See SAP note [684106|https://service.sap.com/sap/support/notes/684106] for details on how to install them.
    Installing the VC redistributable packages from Microsoft will solve this issue.
    Regards,
    Stefan

  • FTP Connection through R/3

    Hi Friends,
      I need to handle file transfer between non SAP system & R/3 application server, in both way. This is to be handled through R/3. and it should be automatic i.e. we need this transferring pgm as scheduled one.
      1. Is there any STD pgm to handle File transfer?
      2. will FTP_Connect, FTP_Command, FTP_disconnect functions work? Becoz i hv tried out with these functions but i was not able to connect to remote     system. Could anybody help me out in this?
      3. & i m not sure about scheduling of these functions?
    Thanks in advance.
    Seema

    HI Seema
    u can write small shell script program ,and store
    these in application server(AL11 Tcode) ,these shell script program should be able to connect to remote server
    and copy file from remote server to your application
    server,
    shell script program:
    Connecting to ftp server to get the file on the current server
    SOURCE_FILE_NAME=TSPAR_`date +%Y%m%d`.txt
    #ur application server path
    TARGET_FILE_NAME="/interf/torrance/TCW/FI/TS_PAR/TSPAR_`date +%Y%m%d`.txt
    BACKUP_FILE="/interf/torrance/TCW/FI/backup/TS_PAR/TSPAR_`date +%Y%m%d`.txt" 
    #ur remote server path
    cd /interf/torrance/TCW/FI/TS_PAR
    ftp -nv << EOF
    open 131.123.233.134
    user e3ty capihg
    get $SOURCE_FILE_NAME
    put $TARGET_FILE_NAME
    get $SOURCE_FILE_NAME $BACKUP_FILE
    EOF
    use function module SXPG_COMMAND_EXECUTE to trigger
    these script and file is there in ur application server.
    pls let me know if you need further input regarding this

  • FTP connections through Finder not reporting correct file size

    Hi,
    I have a NAS that running as an FTP server. When I connect to it through Finder it reports the incorrect file size of 2.7GB (the real file size is 61GB)
    Its an DMG image file so it obviously fails when I try to image a new IMAC.
    FTP through windows reports the correct file size so rules out any problem on the NAS.
    Any ideas anybody?
    Many thanks.

    Hi,
    I have a NAS that running as an FTP server. When I connect to it through Finder it reports the incorrect file size of 2.7GB (the real file size is 61GB)
    Its an DMG image file so it obviously fails when I try to image a new IMAC.
    FTP through windows reports the correct file size so rules out any problem on the NAS.
    Any ideas anybody?
    Many thanks.

  • Unix command in FTP connection through File Adapter

    Hi All,
    I have a scenario IDOC to file in which the user requested for pushing file to FTP server as below
    put localfilename %localfilename%CITISECUFLATNA%CITIGPASSIN%%B
    Here my file name is test.txt.
    so I tried giving in communial channel as
    File Access Parameters
    Target Directoy      : put test.txt %test.txt%CITISECUFLATNA%CITIGPASSIN%%B
    File Name Scheme: text.txt
    But I go the error in Communication channel as
    An error occurred while connecting to the FTP server 'ftp-gw.dx.deere.com:21'. The FTP server returned the following error message: 'com.sap.aii.adapter.file.ftp.FTPEx: 501 Syntax errors in parameter.     usage: %[recipient id]%[APRF]       where either [recipient] or [APRF] can be omitted.            (to change your current default SEND relationship).            %% (places you in your 'HOME' TR).   &['s'|'single'] ('get' command gets single file).   &['m'|'multiple'] ('get' command gets multiple files). '. For details, contact your FTP server vendor
    Please let me know how we can specify in our FTP parameter in Communication chanel.
    Regards,
    Dhill.

    Hi Satish,
      Thank you very much for your help and your time.  But I tried as you told
    Target Directory as : \
    File name scheme : test.txtCITISECUFLATNA%CITIGPASSIN%%B
    and also tried as
    Target Directory as : \
    File name scheme : test.txt<b>%</b>CITISECUFLATNA%CITIGPASSIN%%B
    still i got the same eror....  I am getting success only when I specify like
    Target Directory as : %%
    File name scheme : test.txt
    but the vendor is saying he is not able to see the file anywhere in ftp.
    Regards,
    Dhill

  • Oracle 7.x connection through Java application.

    I have Win98 and Oracle 7.x on my P.C., I am developing an application in Java Menus where under one menu one can get a connection with the underlying Oracle DB. But even after proper JDBC coding I am not able to get the connection. Please help.
    Thnaks,
    Pushpahas.

    Can u be more pecific on the error u r getting may be that way i can help u..
    shravan

  • Mainframe connection through java

    Hi,
    Is it possible to connect to a mainframe and retrieve the results from it i.e., the data stored are in the form of cards(record types).Is it possible to connect to such set up using JDBC connectivity as we do for the normal RDBMS connection..
    Kindly help me in this regards
    Wiht thanks in advance
    subra

    Why on earth should a "mainframe" (you even didn't tell us which OS) be such a magic zone that even Java can't enter it?
    How do other programming languages manage to connnect to a DBMS on a mainframe?
    How has for example Oracle succeeded to be used on mainframes?
    I think you should ask your DBMS' vendor at first.
    "Mainframe" is a collective name for certain hardware structures only.

  • Getting result from a telnet command through Java

    Hi,
    I've been using a set of classes found here: http://javatelnet.org/
    to do telnet through Java in a non-interactive mode.
    However I've got a problem when retrieving the result of a command sent to the remote host: the classes read the stream until the prompt is encountered; my problem is I must execute commands on several remote hosts, and the prompt is not necessarily the same on all hosts.
    Is there a simple means to establish a telnet connection through Java and retrieve the result of the commands?
    Any help would be appreciated.

    Thanks again, this is a very good article
    I see it is still the same strategy to get the result of a command : wait 'til the prompt is sent. Maybe there is just no other way to get it .
    But as I don't know the prompt on the different hosts I have to query, this won't do it.
    The article gave me an idea though : I only need to count the files in a directory on the remote host; until now I was trying to send the 'ls | wc -l' command by Telnet.
    Maybe I can simply do it by FTP (retrieve the list of files, and then count the lines with JAVA).

  • Connect to FTP site with Apache commons net FTP client through Proxy

    Hello,
    I am trying to run this simple code to connect to FTP site through a proxy.
    import org.apache.commons.net.ftp.FTP;
    import org.apache.commons.net.ftp.FTPClient;
    public class MyTest {
    public static void main(String[] args) {
    String ftpHostName = "ftp.xxx.com";
    int ftpPort = 21;
    String ftpUserName = "myUserName";
    String ftpPassword = "myPassword";
    System.setProperty("socksProxyHost" ,"10.148.0.131");
    System.setProperty("socksProxyPort", "1080");
    FTPClient ftpClient = new FTPClient();
    try {
    System.out.println("connecting");
    ftpClient.connect(ftpHostName, ftpPort);
    System.out.println("connected");
    System.out.println("loging in");
    boolean successLogin = ftpClient.login(ftpUserName, ftpPassword);
    if(successLogin)
    System.out.println("success login");
    else
    System.out.println("fail login");
    catch (Exception e) {
    e.printStackTrace();
    finally {
    try {
    System.out.println("loging out");
    ftpClient.logout();
    System.out.println("disconecting");
    ftpClient.disconnect();
    catch (Exception e) {
    e.printStackTrace();
    I am getting the following error:
    C:\temp\ftp\test>java.exe -cp ./commons-net-ftp-2.0.jar;. MyTest connecting
    java.net.SocketException: Malformed reply from SOCKS server
    at java.net.SocksSocketImpl.readSocksReply(SocksSocketImpl.java:87)
    at java.net.SocksSocketImpl.connectV4(SocksSocketImpl.java:265)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:437)
    at java.net.Socket.connect(Socket.java:519)
    at org.apache.commons.net.SocketClient.connect(SocketClient.java:176)
    at MyTest.main(MyTest.java:23)
    loging out
    java.lang.NullPointerException
    at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:471<ftp://FTP.java:471>)
    at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:534<ftp://FTP.java:534>)
    at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:583<ftp://FTP.java:583>)
    at org.apache.commons.net.ftp.FTP.quit(FTP.java:794<ftp://FTP.java:794>)
    at org.apache.commons.net.ftp.FTPClient.logout(FTPClient.java:697)
    at MyTest.main(MyTest.java:39)
    I am able to do this using a different FTP client library, ftp4j-1.5.1<ftp://ftp4j-1.5.1> using the following code:
    import it.sauronsoftware.ftp4j.FTPClient;
    import it.sauronsoftware.ftp4j.connectors.SOCKS4Connector;
    public class MyTestFtp4J {
    public static void main(String[] args) {
    String ftpHostName = "ftp.xxx.com";
    int ftpPort = 21;
    String ftpUserName = "myUserName";
    String ftpPassword = "myPassword";
    FTPClient ftpClient = new FTPClient();
    ftpClient.setConnector(new SOCKS4Connector("10.148.0.131", 1080));
    try {
    System.out.println("connecting");
    ftpClient.connect(ftpHostName, ftpPort);
    System.out.println("connected");
    System.out.println("loging in");
    ftpClient.login(ftpUserName, ftpPassword);
    System.out.println("success login");
    catch (Exception e) {
    e.printStackTrace();
    finally {
    try {
    System.out.println("disconecting");
    ftpClient.disconnect(true);
    catch (Exception e) {
    e.printStackTrace();
    So I know the proxy settings are correct.
    The java version I used to compile and run my apps is 1.6.0_06 Does anyone can help figure out what is wrong when I use the Apache commons net FTP client?
    Thank you
    Jon

    Is the old AirPort Extreme base station (AEBS)
    configured so that the option to distribute IP
    addresses is DISABLED? If so, configure the new AEBS
    to act as a bridge.
    Are you suggesting I use a set-up with TWO AEBSs? Set up a bridge (not sure how) and then use the old AEBS to connect to the DSL modem and broadcast to the new Extreme which will then be the router to the other computers on the network?
    Do you have any port mapping or default host enabled
    on the old AEBS?
    I do not understand, not do I see these options in the Base Station utitlity; perhaps they are in the FTP options--but that, I'm sorry to say, is not obvious to my inspection.
    Duane, can you give me a few more basic instructions? Thanks
    iMac 17    

  • File has to pass through FTPS connection.. Connection parameters?

    Hi,
    I want to transfer the file through FTPS connection. Partner side provided the following details as connection parameters.
    - IP : 129.32.169.140 
    - POrt: 990
    User name
    Password
    PASV mode
    SSL Direct, OpenSSL,SSL Listing, SSL Transfers.
    Kindly let me know what are all the parameters I need to pass in Receiver file adapter.
    FTP Connection Parameters:
    Server
    Port
    Data connection: Passive
    Connection Security:  FTPS for control connection or FTPS for control and Data connection.???
    Command Order :  ?????
    Please let me know what are the security and command order parameters I need to use in Receiver file adapter.
    They didn't provide any certificates.
    Thanks
    Deepthi.

    Hi Rajesh,
    The message is not even failing.. It is in the status of "Delivering". The below are the logs from adapter and Messaging system.
    File Adapter Log:
    Success   Message successfully received by messaging system. Profile: XI URL: http://xi-dev.intranet.XI.com.au:50200/MessagingSystem/receive/AFW/XI Credential (User): PIISUSER
    Success  Using connection File_http://sap.com/xi/XI/System. Trying to put the message into the receive queue.
    Success  Message successfully put into the queue.
    Success  The message was successfully retrieved from the receive queue.
    messaging system log:
    Message ID  44b756da-d9bd-42e2-3136-e34d75adfe03 
    Message Type  Asynchronously Received Message (RECEIVE) 
    From Service   Name:  BS_1  
    To Service   Name:  BS2  
    Action   Namespace  http://XI.com/SAP_PI/ControlData Name:  BYPASS  
    Connection Name   File_http://sap.com/xi/XI/System 
    Status   Delivering 
    Error Category    
    Error Code    
    Profile   XI 
    Transport   HTTP 
    Delivery Semantics   Exactly Once 
    Times Failed   0 
    Number of Retries   3 
    Sent / Received  09/09/2009 11:22:52 
    Transmitted / Delivered  09/09/2009 11:22:53 
    Next Delivery  09/09/2009 11:22:53 
    Persist Until  10/09/2009 11:22:52 
    Valid Until  01/01/1970 10:00:00 
    Retry Interval   5 Minutes 
    Address   http://xi-dev.intranet.XI.com.au:50200/MessagingSystem/receive/AFW/XI 
    Transport Headers   authorization=Basic UElJU1VTRVI6dDFhbTRyaWE= Content-Length=3010 accept-encoding=gzip sap-xi-messageid=44B756DAD9BD42E23136E34D75ADFE03 content-length=3024 host=xi-dev.intranet.XI.com.au:50200 user-agent=SAP Web Application Server (1.0;700) content-type=multipart/related;boundary=SAP_4AA4E14330050131E10080000A722149_END;type="text/xml";start="" HTTP=POST soapaction="http://sap.com/xi/XI/Message/30" 
    Principal Propagation

Maybe you are looking for

  • Importing clips longer than 4min - crashes computer - genral error34 in FCP

    importing clips longer than 4min - crashes computer - genral error34 in FCP Posted: Dec 21, 2008 10:48 AM Reply Email FCP HD 4.5 not taking clips longer than 4min and in FCP Im getting ( general error 34) in my audio/video settings. Computer crashes

  • Reconciliation Account question

    Friends, I know that we can have multiple reconciliation accounts(for AR and AP) or we can have one per each subledgers. But my question is,  what typically happens in a real project? do you have to create multiple accounts or just one Reconciliation

  • SCCM 2012 Console not accessible - SMSAdminUI.log - Error Code : ProviderLoadFailure

    Hello Team,         The site server which was working fine is now not accessible, unable to connect the console "Configuration manager cannot connect to the site" * It is a standalone Primary with provide installed on the same server *  Recently Upgr

  • Ssl web service call problem

    Hi, I have a form that calls a web service on start up in the docReady event. This has been working well in one of our development environments where the the web service is on a plain non secure connection. However, when we try and make the same web

  • Setting multiple maxdepth levels

    Hello, This sample code seems to work fine: find /Users/username/Desktop /Users/username/Documents /Users/username/Library -name foo -prune -maxdepth 3 but my question is how can I set a different maxdepth level for each directory? Thank you, Rick