kent

Greenhorn
+ Follow
since Dec 02, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by kent

Hi,
I wish to know whether a database session can be terminated earlier than web session which is binding the database session. The database session is bound to the web session upon database login by:
1. javax.servlet.http.HttpSessionBindingListener;
2. javax.servlet.http.HttpSessionBindingEvent;
Both the database session and web session are set to timeout in 60 minutes.
When we do an experiment to manually terminate the database session after 30 minutes, our expected result is that no record can be added to the database from the web application after 30 minutes. We test this because there is a possiblility that the database session may end earlier than web session for unknow reason.
But our test result shows that record still can be added to database after 30 minutes.
1. What is the cause of this unexpected result ?
2. What is the supposed result ?

Thanks in advance.
20 years ago
Hi,
I wish to know whether a database session can be terminated earlier than web session which is binding the database session. The database session is bound to the web session upon database login by:
1. javax.servlet.http.HttpSessionBindingListener;
2. javax.servlet.http.HttpSessionBindingEvent;
Both the database session and web session are set to timeout in 60 minutes.
When we do an experiment to manually terminate the database session after 30 minutes, our expected result is that no record can be added to the database from the web application after 30 minutes. We test this because there is a possiblility that the database session may end earlier than web session for unknow reason.
But our test result shows that record still can be added to database after 30 minutes.
1. What is the cause of this unexpected result ?
2. What is the supposed result ?

Thanks in advance.
20 years ago
Didnt I close all the opened file?
20 years ago
result still same as above
Help me
20 years ago
I have close the ftp before deleting the transferred file, but the result still same.
Any idea what was wrong?
Thanks.
20 years ago
Dear all,
My problem here is after I ran my code, I cant delete the origin file that I have ftp it. For example, I ftp C:\a\a.txt to /home/kwwong/upload/a.txt. After doing this, I need to delete C:\a\a.txt but I got this message "Cannot delete a.txt:It is being used by another person or program".
Anyone knows what wrong with my code here?
Any helps are appreciated. Thank you very much.
BufferedReader reader = null;
Ftp ftp = null;
String tmp = null;
InetAddress Inet = null;
try{
String lStrUploadFileLog = "C:/FTPLog/FTPLog_05122003.log";
String lStrUploadFilePath = "/home/kwwong/upload/";
String lStrFTP_USER = "kwwong";
String lStrFTP_PWD = "password";
String lStrFTP_IP = "192.168.1.100";
String lStrLogFileDate= "LOG_FILE_DATE";
reader = new BufferedReader(new FileReader(new File(lStrUploadFileLog)));
Inet = InetAddress.getByName(lStrFTP_IP);
tmp = reader.readLine();
ftp = new Ftp(Inet,lStrFTP_USER,lStrFTP_PWD);
ftp.setType(ftp.BINARY);

if(tmp != null){
System.out.println("lStrUploadFileLog = "+lStrUploadFileLog);
System.out.println("lStrUploadFilePath+lStrLogFileDate = "+(lStrUploadFilePath+lStrLogFileDate));
ftp.startPut(lStrUploadFileLog,lStrUploadFilePath+lStrLogFileDate);
System.out.println("tmp = "+tmp);
StringTokenizer strtmp = new StringTokenizer(tmp,",");
int size_strtmp = strtmp.countTokens();

while (size_strtmp>0){
String lStrUploadFile = strtmp.nextToken();
size_strtmp--;
StringTokenizer strlStrUploadFile = new StringTokenizer(lStrUploadFile,"\\");
int size_strlStrUploadFile = strlStrUploadFile.countTokens();
String substr = lStrUploadFile.substring(lStrUploadFile.lastIndexOf("\\")+1,lStrUploadFile.length());

ftp.startPut(lStrUploadFile,lStrUploadFilePath+substr);
ftp.waitUntilTransferComplete();

System.out.println("File(s) download completed!");
}
try {
File ff = new File(lStrUploadFileLog);
System.out.println(ff.getAbsolutePath());
boolean state = ff.delete();
System.out.println(state);
} catch ( SecurityException se ) {
System.out.println("Error SecurityException: "+se );
se.printStackTrace();
}
catch(Exception e){
System.out.println("Error Exception1: "+e );
e.printStackTrace();
}
}
System.out.println("Upload to server completed!!!");
}catch(Exception e){

System.out.println("Error Exception: "+e);
}
finally{
if(reader != null)
reader.close();
if(ftp != null)
ftp.close();
reader= null;
ftp= null;
tmp = null;
Inet = null;
}
20 years ago
Dear all,
My problem here is after I ran my code, I cant delete the origin file that I have ftp it. For example, I ftp C:\a\a.txt to /home/kwwong/upload/a.txt. After doing this, I need to delete C:\a\a.txt but I got this message "Cannot delete a.txt:It is being used by another person or program".
Anyone knows what wrong with my code here?
Any helps are appreciated. Thank you very much.
BufferedReader reader = null;
Ftp ftp = null;
String tmp = null;
InetAddress Inet = null;
try{
String lStrUploadFileLog = "C:/FTPLog/FTPLog_05122003.log";
String lStrUploadFilePath = "/home/kwwong/upload/";
String lStrFTP_USER = "kwwong";
String lStrFTP_PWD = "password";
String lStrFTP_IP = "192.168.1.100";
String lStrLogFileDate= "LOG_FILE_DATE";
reader = new BufferedReader(new FileReader(new File(lStrUploadFileLog)));
Inet = InetAddress.getByName(lStrFTP_IP);
tmp = reader.readLine();
ftp = new Ftp(Inet,lStrFTP_USER,lStrFTP_PWD);
ftp.setType(ftp.BINARY);

if(tmp != null){
System.out.println("lStrUploadFileLog = "+lStrUploadFileLog);
System.out.println("lStrUploadFilePath+lStrLogFileDate = "+(lStrUploadFilePath+lStrLogFileDate));
ftp.startPut(lStrUploadFileLog,lStrUploadFilePath+lStrLogFileDate);
System.out.println("tmp = "+tmp);
StringTokenizer strtmp = new StringTokenizer(tmp,",");
int size_strtmp = strtmp.countTokens();

while (size_strtmp>0){
String lStrUploadFile = strtmp.nextToken();
size_strtmp--;
StringTokenizer strlStrUploadFile = new StringTokenizer(lStrUploadFile,"\\");
int size_strlStrUploadFile = strlStrUploadFile.countTokens();
String substr = lStrUploadFile.substring(lStrUploadFile.lastIndexOf("\\")+1,lStrUploadFile.length());

ftp.startPut(lStrUploadFile,lStrUploadFilePath+substr);
ftp.waitUntilTransferComplete();

System.out.println("File(s) download completed!");
}
try {
File ff = new File(lStrUploadFileLog);
System.out.println(ff.getAbsolutePath());
boolean state = ff.delete();
System.out.println(state);
} catch ( SecurityException se ) {
System.out.println("Error SecurityException: "+se );
se.printStackTrace();
}
catch(Exception e){
System.out.println("Error Exception1: "+e );
e.printStackTrace();
}
}
System.out.println("Upload to server completed!!!");
}catch(Exception e){

System.out.println("Error Exception: "+e);
}
finally{
if(reader != null)
reader.close();
if(ftp != null)
ftp.close();
reader= null;
ftp= null;
tmp = null;
Inet = null;
}
Dear all,
My problem here is after I ran my code, I cant delete the origin file that I have ftp it. For example, I ftp C:\a\a.txt to /home/kwwong/upload/a.txt. After doing this, I need to delete C:\a\a.txt but I got this message "Cannot delete a.txt:It is being used by another person or program".
Anyone knows what wrong with my code here?
Any helps are appreciated. Thank you very much.
BufferedReader reader = null;
Ftp ftp = null;
String tmp = null;
InetAddress Inet = null;
try{
String lStrUploadFileLog = "C:/FTPLog/FTPLog_05122003.log";
String lStrUploadFilePath = "/home/kwwong/upload/";
String lStrFTP_USER = "kwwong";
String lStrFTP_PWD = "password";
String lStrFTP_IP = "192.168.1.100";
String lStrLogFileDate= "LOG_FILE_DATE";
reader = new BufferedReader(new FileReader(new File(lStrUploadFileLog)));
Inet = InetAddress.getByName(lStrFTP_IP);
tmp = reader.readLine();
ftp = new Ftp(Inet,lStrFTP_USER,lStrFTP_PWD);
ftp.setType(ftp.BINARY);

if(tmp != null){
System.out.println("lStrUploadFileLog = "+lStrUploadFileLog);
System.out.println("lStrUploadFilePath+lStrLogFileDate = "+(lStrUploadFilePath+lStrLogFileDate));
ftp.startPut(lStrUploadFileLog,lStrUploadFilePath+lStrLogFileDate);
System.out.println("tmp = "+tmp);
StringTokenizer strtmp = new StringTokenizer(tmp,",");
int size_strtmp = strtmp.countTokens();

while (size_strtmp>0){
String lStrUploadFile = strtmp.nextToken();
size_strtmp--;
StringTokenizer strlStrUploadFile = new StringTokenizer(lStrUploadFile,"\\");
int size_strlStrUploadFile = strlStrUploadFile.countTokens();
String substr = lStrUploadFile.substring(lStrUploadFile.lastIndexOf("\\")+1,lStrUploadFile.length());

ftp.startPut(lStrUploadFile,lStrUploadFilePath+substr);
ftp.waitUntilTransferComplete();

System.out.println("File(s) download completed!");
}
try {
File ff = new File(lStrUploadFileLog);
System.out.println(ff.getAbsolutePath());
boolean state = ff.delete();
System.out.println(state);
} catch ( SecurityException se ) {
System.out.println("Error SecurityException: "+se );
se.printStackTrace();
}
catch(Exception e){
System.out.println("Error Exception1: "+e );
e.printStackTrace();
}
}
System.out.println("Upload to server completed!!!");
}catch(Exception e){

System.out.println("Error Exception: "+e);
}
finally{
if(reader != null)
reader.close();
if(ftp != null)
ftp.close();
reader= null;
ftp= null;
tmp = null;
Inet = null;
}
20 years ago
Dear all,
My problem here is after I ran my code, I cant delete the origin file that I have ftp it. For example, I ftp C:\a\a.txt to /home/kwwong/upload/a.txt. After doing this, I need to delete C:\a\a.txt but I got this message "Cannot delete a.txt:It is being used by another person or program".
Anyone knows what wrong with my code here?
Any helps are appreciated. Thank you very much.
BufferedReader reader = null;
Ftp ftp = null;
String tmp = null;
InetAddress Inet = null;
try{
String lStrUploadFileLog = "C:/FTPLog/FTPLog_05122003.log";
String lStrUploadFilePath = "/home/kwwong/upload/";
String lStrFTP_USER = "kwwong";
String lStrFTP_PWD = "password";
String lStrFTP_IP = "192.168.1.100";
String lStrLogFileDate= "LOG_FILE_DATE";
reader = new BufferedReader(new FileReader(new File(lStrUploadFileLog)));
Inet = InetAddress.getByName(lStrFTP_IP);
tmp = reader.readLine();
ftp = new Ftp(Inet,lStrFTP_USER,lStrFTP_PWD);
ftp.setType(ftp.BINARY);

if(tmp != null){
System.out.println("lStrUploadFileLog = "+lStrUploadFileLog);
System.out.println("lStrUploadFilePath+lStrLogFileDate = "+(lStrUploadFilePath+lStrLogFileDate));
ftp.startPut(lStrUploadFileLog,lStrUploadFilePath+lStrLogFileDate);
System.out.println("tmp = "+tmp);
StringTokenizer strtmp = new StringTokenizer(tmp,",");
int size_strtmp = strtmp.countTokens();

while (size_strtmp>0){
String lStrUploadFile = strtmp.nextToken();
size_strtmp--;
StringTokenizer strlStrUploadFile = new StringTokenizer(lStrUploadFile,"\\");
int size_strlStrUploadFile = strlStrUploadFile.countTokens();
String substr = lStrUploadFile.substring(lStrUploadFile.lastIndexOf("\\")+1,lStrUploadFile.length());

ftp.startPut(lStrUploadFile,lStrUploadFilePath+substr);
ftp.waitUntilTransferComplete();

System.out.println("File(s) download completed!");
}
try {
File ff = new File(lStrUploadFileLog);
System.out.println(ff.getAbsolutePath());
boolean state = ff.delete();
System.out.println(state);
} catch ( SecurityException se ) {
System.out.println("Error SecurityException: "+se );
se.printStackTrace();
}
catch(Exception e){
System.out.println("Error Exception1: "+e );
e.printStackTrace();
}
}
System.out.println("Upload to server completed!!!");
}catch(Exception e){

System.out.println("Error Exception: "+e);
}
finally{
if(reader != null)
reader.close();
if(ftp != null)
ftp.close();
reader= null;
ftp= null;
tmp = null;
Inet = null;
}
20 years ago