📄 ftpclient.java
字号:
package com.socket;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.ResourceBundle;
import java.util.TimerTask;
import merp.sc.server.dba.common.DBA_Common;
public class FtpClient extends TimerTask {
private ResourceBundle _config = null;
private DBA_Common dba_Common = null;
private Connection conn = null;
//读取配置文件
public FtpClient() {
try {
_config = ResourceBundle.getBundle("ftpclient");
} catch (Exception e) {
System.out.println("[SYS] Cann't load file: ftpclient.properties.");
}
}
// 连接数据库
private void connDBA() {
try {
if (conn == null || conn.isClosed()) {
dba_Common = new DBA_Common();
conn = dba_Common.initDBA(null, "1");
}
dba_Common.setConnection(conn);
} catch (Exception e) {
System.out.println("[SYS] SMS ReplyTask.connDBA() Exception: "
+ e.toString());
}
}
//释放资源
private void freeDBA() {
try {
if (conn != null || !conn.isClosed()) {
dba_Common.closeDBA(conn);
conn = null;
dba_Common = null;
}
} catch (Exception e) {
System.out.println("[SYS] SMS ReplyTask.freeDBA() Exception: "
+ e.toString());
}
}
public void start() {
StringBuffer strSqlBuf = new StringBuffer();
strSqlBuf.append("SELECT I_ID,VC_FILENAME,VC_FILESIZE").append(
" FROM JCMS_SYNC_ATTACH").append(
" WHERE B_ISSYNC=0 AND ROWNUM<20").append(" ORDER BY I_ID ASC");
String[][] strData = dba_Common.loadDataFromDB(null, strSqlBuf
.toString(), false);
strSqlBuf.delete(0, strSqlBuf.length());
ArrayList fileList = new ArrayList();
if (strData != null && strData.length > 0) {
int nLen = strData.length;
for (int i = 0; i < nLen; i++) {
fileList.add(i, new FtpFileProps(strData[i][0], strData[i][1],
strData[i][2]));
}
}
//创建线程
if (fileList != null) {
int len = fileList.size();
for (int i = 0; i < len; i++) {
FtpFileProps file = (FtpFileProps) fileList.get(i);
System.out.println("[SYS] Thread " + i + " create with task \""
+ file.getFilename() + "\" " + file.getFilesize()
+ " Byte.");
new FtpClientThread(_config, file, Integer.toString(i));
}
}
}
public void run() {
connDBA();
start();
freeDBA();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -