📄 logentity.java
字号:
package org.indigo.db;
import java.io.File;
import java.sql.Date;
import org.indigo.util.MainConfig;
/**
* 此类主要是为把每天的日志记录插入数据库中而写。
* 它是一个日志记录封装类。
* @author wbz
*
*/
public class LogEntity {
private String PATH ;
private String TOTAL ;
private String WHYCODE ;
private String WHYSTRING ;
private Date time ;
private String zeroCode;
private String rootPath;
private String RePath;
private static int counter=0;
public String getPATH() {
return PATH;
}
public void setPATH(String path) {
File file=new File(path);
PATH=file.getAbsolutePath();
// System.out.println(PATH);
//PATH = path;
}
public Date getTime() {
return new Date(new java.util.Date().getTime());
}
public void setTime(Date time) {
this.time = time;
}
public String getTOTAL() {
return TOTAL;
}
public void setTOTAL(String total) {
TOTAL = total;
}
public String getWHYCODE() {
if(WHYCODE==null)
WHYCODE="";
return WHYCODE.replaceAll("'", "");
}
public void setWHYCODE(String whycode) {
if(whycode==null)
whycode="";
WHYCODE = whycode;
}
public String getWHYSTRING() {
if(WHYSTRING==null)
WHYSTRING="";
return WHYSTRING.replaceAll("'", "");
}
public void setWHYSTRING(String whystring) {
if(whystring==null)
whystring="";
WHYSTRING = whystring;
}
/**
* 把采集过程中所产生的日志对象的属性获取过来,
* 然后插入到oracle数据库中。
*
*/
public void Execute()
{
time=new Date(new java.util.Date().getTime());
getRootPath();
String sql="insert into LogRecord values(2,'"+PATH+"',"+"'"+TOTAL+"','"+WHYCODE+"','"+zeroCode+"','"+WHYSTRING+"',"
+"to_date('"+time+"','yyyy-mm-dd'),'"+rootPath+"')";
DBOracleConnection.getInstance().executeInsert(sql);
System.out.println(++counter);
System.out.println("日志已经插入数据库");
}
public static void main(String args[])
{
LogEntity log=new LogEntity();
log.setPATH("taskconfig/农业网站/一站通_new.task");
//log.setPATH("www");
log.setTOTAL("200");
log.setWHYCODE("why");
log.setWHYSTRING("xay");
log.setZeroCode("zero");
log.Execute();
}
public String getZeroCode() {
if(zeroCode==null)
zeroCode="";
return zeroCode.replaceAll("'", "");
}
public void setZeroCode(String zeroCode) {
if(zeroCode==null)
zeroCode="";
this.zeroCode = zeroCode;
}
public String getRootPath() {
rootPath=MainConfig.getInstance().getProperty( "TaskConfigRoot" )+"\\"+RePath;
return rootPath;
}
public String getRePath() {
return RePath;
}
public void setRePath(String rePath) {
int k=-1;
k=rePath.indexOf("/");
while(k!=-1)
{
String temp=rePath.substring(0, k);
String last=rePath.substring(k+1);
rePath=temp+"\\"+last;
k=rePath.indexOf("/");
}
RePath = rePath;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -