Ready to get started?

Download a free trial of the FTP Driver to get started:

 Download Now

Learn more:

FTP Icon FTP JDBC Driver

An easy-to-use database-like interface for Java based applications and reporting tools access to remote files and directories.

Connect to FTP Data from a Connection Pool in Jetty

The FTP JDBC Driver supports connection pooling: This article shows how to connect faster to FTP data from Web apps in Jetty.

The CData JDBC driver for FTP is easy to integrate with Java Web applications. This article shows how to efficiently connect to FTP data in Jetty by configuring the driver for connection pooling. You will configure a JNDI resource for FTP in Jetty.

Configure the JDBC Driver for Salesforce as a JNDI Data Source

Follow the steps below to connect to Salesforce from Jetty.

  1. Enable the JNDI module for your Jetty base. The following command enables JNDI from the command-line:

    java -jar ../start.jar --add-to-startd=jndi
  2. Add the CData and license file, located in the lib subfolder of the installation directory, into the lib subfolder of the context path.
  3. Declare the resource and its scope. Enter the required connection properties in the resource declaration. This example declares the FTP data source at the level of the Web app, in WEB-INF\jetty-env.xml.

    <Configure id='ftpdemo' class="org.eclipse.jetty.webapp.WebAppContext"> <New id="ftpdemo" class=""> <Arg><Ref refid="ftpdemo"/></Arg> <Arg>jdbc/ftpdb</Arg> <Arg> <New class="cdata.jdbc.ftp.FTPDriver"> <Set name="url">jdbc:ftp:</Set> <Set name="RemoteHost">MyFTPServer</Set> </New> </Arg> </New> </Configure>

    To connect to FTP or SFTP servers, specify at least RemoteHost and FileProtocol. Specify the port with RemotePort.

    Set User and Password to perform Basic authentication. Set SSHAuthMode to use SSH authentication. See the Getting Started section of the data provider help documentation for more information on authenticating via SSH.

    Set SSLMode and SSLServerCert to secure connections with SSL.

    The data provider lists the tables based on the available folders in your FTP server. Set the following connection properties to control the relational view of the file system:

    • RemotePath: Set this to the current working directory.
    • TableDepth: Set this to control the depth of folders to list as views.
    • FileRetrievalDepth: Set this to retrieve and list files recursively from the root table.

    Stored Procedures are available to download files, upload files, and send protocol commands. See the Data Model chapter of the FTP data provider documentation for more information.

  4. Configure the resource in the Web.xml:

    jdbc/ftpdb javax.sql.DataSource Container
  5. You can then access FTP with a lookup to java:comp/env/jdbc/ftpdb: InitialContext ctx = new InitialContext(); DataSource myftp = (DataSource)ctx.lookup("java:comp/env/jdbc/ftpdb");

More Jetty Integration

The steps above show how to configure the driver in a simple connection pooling scenario. For more use cases and information, see the Working with Jetty JNDI chapter in the Jetty documentation.