List of usage examples for org.apache.commons.net.ftp FTPClient getConnectTimeout
public int getConnectTimeout()
From source file:ftp.search.Index.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed try {// w ww .j av a 2 s . co m // TODO add your handling code here: Class.forName("com.mysql.jdbc.Driver"); String uid = "root"; String pwd = "clever"; String dbURL = "jdbc:mysql://localhost:3306/ftp"; Connection conn = DriverManager.getConnection(dbURL, uid, pwd); Statement statement = conn.createStatement(); FTPClient ftpClient = new FTPClient(); String ftp = jTextField1.getText(); int port = 21; try { ftpClient.connect(ftp, port); int a = ftpClient.getConnectTimeout(); ftpClient.login("anonymous", ""); // lists files and directories in the current working directory insertFiles(ftp, "/", statement, ftpClient); JOptionPane.showMessageDialog(this, "Files Indexed Successfully"); ftpClient.logout(); ftpClient.disconnect(); } catch (IOException ex) { Logger.getLogger(Index.class.getName()).log(Level.SEVERE, null, ex); } } catch (ClassNotFoundException ex) { Logger.getLogger(Index.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) { Logger.getLogger(Index.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:net.seedboxer.camel.component.file.remote.ftp2.Ftp2Endpoint.java
@Override public RemoteFileOperations<FTPFile> createRemoteFileOperations() throws Exception { // configure ftp client FTPClient client = ftpClient; if (client == null) { // must use a new client if not explicit configured to use a custom client client = createFtpClient();/*from w w w . j av a 2s . co m*/ } // set any endpoint configured timeouts if (getConfiguration().getConnectTimeout() > -1) { client.setConnectTimeout(getConfiguration().getConnectTimeout()); } if (getConfiguration().getSoTimeout() > -1) { soTimeout = getConfiguration().getSoTimeout(); } dataTimeout = getConfiguration().getTimeout(); // then lookup ftp client parameters and set those if (ftpClientParameters != null) { // setting soTimeout has to be done later on FTPClient (after it has connected) Object timeout = ftpClientParameters.remove("soTimeout"); if (timeout != null) { soTimeout = getCamelContext().getTypeConverter().convertTo(int.class, timeout); } // and we want to keep data timeout so we can log it later timeout = ftpClientParameters.remove("dataTimeout"); if (timeout != null) { dataTimeout = getCamelContext().getTypeConverter().convertTo(int.class, dataTimeout); } IntrospectionSupport.setProperties(client, ftpClientParameters); } if (ftpClientConfigParameters != null) { // client config is optional so create a new one if we have parameter for it if (ftpClientConfig == null) { ftpClientConfig = new FTPClientConfig(); } IntrospectionSupport.setProperties(ftpClientConfig, ftpClientConfigParameters); } if (dataTimeout > 0) { client.setDataTimeout(dataTimeout); } if (log.isDebugEnabled()) { log.debug("Created FTPClient [connectTimeout: {}, soTimeout: {}, dataTimeout: {}]: {}", new Object[] { client.getConnectTimeout(), getSoTimeout(), dataTimeout, client }); } Ftp2Operations operations = new Ftp2Operations(client, getFtpClientConfig()); operations.setEndpoint(this); return operations; }
From source file:org.apache.camel.component.file.remote.FtpEndpoint.java
public RemoteFileOperations<FTPFile> createRemoteFileOperations() throws Exception { // configure ftp client FTPClient client = ftpClient; if (client == null) { // must use a new client if not explicit configured to use a custom client client = createFtpClient();//from w w w . j a va2 s. c om } // set any endpoint configured timeouts if (getConfiguration().getConnectTimeout() > -1) { client.setConnectTimeout(getConfiguration().getConnectTimeout()); } if (getConfiguration().getSoTimeout() > -1) { soTimeout = getConfiguration().getSoTimeout(); } dataTimeout = getConfiguration().getTimeout(); // then lookup ftp client parameters and set those if (ftpClientParameters != null) { Map<String, Object> localParameters = new HashMap<String, Object>(ftpClientParameters); // setting soTimeout has to be done later on FTPClient (after it has connected) Object timeout = localParameters.remove("soTimeout"); if (timeout != null) { soTimeout = getCamelContext().getTypeConverter().convertTo(int.class, timeout); } // and we want to keep data timeout so we can log it later timeout = localParameters.remove("dataTimeout"); if (timeout != null) { dataTimeout = getCamelContext().getTypeConverter().convertTo(int.class, dataTimeout); } setProperties(client, localParameters); } if (ftpClientConfigParameters != null) { // client config is optional so create a new one if we have parameter for it if (ftpClientConfig == null) { ftpClientConfig = new FTPClientConfig(); } Map<String, Object> localConfigParameters = new HashMap<String, Object>(ftpClientConfigParameters); setProperties(ftpClientConfig, localConfigParameters); } if (dataTimeout > 0) { client.setDataTimeout(dataTimeout); } if (log.isDebugEnabled()) { log.debug("Created FTPClient [connectTimeout: {}, soTimeout: {}, dataTimeout: {}]: {}", new Object[] { client.getConnectTimeout(), getSoTimeout(), dataTimeout, client }); } FtpOperations operations = new FtpOperations(client, getFtpClientConfig()); operations.setEndpoint(this); return operations; }