commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Drew <>
Subject RE: FTPClient within Oracle RDBMS problem
Date Wed, 26 May 2004 11:38:43 GMT

As long as you're trying things, why don't you try commons net v1.2.1?  Who
knows--it might work.


-----Original Message-----
From: Thomas Stiegler [] 
Sent: Wednesday, May 26, 2004 4:23 AM
Subject: FTPClient within Oracle RDBMS problem

I use the Jakarta commons net java classes v1.1 to transfer data via
ftp from within a PL/SQL procedure in the RDBMS without using a local
temporary file. The code fragments below show the principle.

This technique works pretty well on any Linux distributions and any
RDMBS version (8i, 9i both in several releases). But if I try to use
it on any Windows OS (checked with WinNT 4 SP6a, Win2000 SP3, WinXP
Pro SP1 and with many RDMBS versions - 8.1.6, 8.1.7,,
the systems hangs often during the second call to the get method.
After that I have to shutdown the db and sometimes to reboot the
server to be able to transfer another file. This behavior is
reproducable in general and occours on any Windows OS and any RDBMS
mentioned above. Further investigations show that the first call of
any FTP function after the successful login always causes the system
to hang. The login process itself is always succesful. Using active or
passive mode makes no sense. It seems to me there may occour a
communication situation the common net ftp class can not handle inside
the PL/SQL environment respectively within the internal JVM on a
Windows OS.

Any hints to resolve this situation would be highly appreciated.

Regards, Tom.

Code fragments:

class FTP {
public boolean login(String sHost, String sUser, String sPassword)
throws IOException {
fc = new FTPClient();
if (logReply() >= 500) return false;
if(!FTPReply.isPositiveCompletion(fc.getReplyCode())) {
return false;
boolean bOk = fc.login(sUser, sPassword);
if (logReply() >= 500) return false;
return bOk;

public int getInTable(String sTable, String sDir, String sFile,
Connection c)
throws Exception {
byte b[] = new byte[4000];
int iID = 0;
int iSeq = 0;

PreparedStatement pstmt = c.prepareStatement(
ResultSet rs = pstmt.executeQuery();
if ( iID = rs.getInt(1);

pstmt = c.prepareStatement(
"INSERT INTO " + sTable + " (ID, SEQ, DATA) VALUES(?, ?, ?)");

if (!sDir.equals("")) {
if (logReply() >= 500) return -1;

InputStream is = fc.retrieveFileStream(sFile);
if (logReply() >= 500) return -1;
if (is == null) return -1;

long lStart = System.currentTimeMillis();
int iBytesRead;
while((iBytesRead =, 0, 4000)) > -1) {
pstmt.setInt(1, iID);
pstmt.setInt(2, iSeq++);
pstmt.setString(3, new String(b, 0, iBytesRead));
iBytes += iBytesRead;
if (logReply() >= 500) return -1;
return iID;


Thomas Stiegler

k+n Informationssysteme GmbH
Ringstrasse 45
D-09247 Roehrsdorf

Phone: +49-(0)3722-5235-0
Fax: +49-(0)3722-5235-20

To unsubscribe, e-mail:
For additional commands, e-mail:

NOTICE: This communication contains information which is confidential to
Realm Business Solutions, Inc. or its subsidiary ("Realm"). If you are not
the intended recipient of this communication, please delete and destroy all
copies. If you are the intended recipient of this communication, you should
not copy, disclose or distribute this communication without Realm's
authority. Any views expressed in this communication are those of the
individual sender, except where the sender specifically states them to be
Realm's views. Except as required by law, Realm does not represent, warrant
or guarantee that the integrity of this communication has been maintained
nor that the communication is free of errors, virus, interception or

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message