java实现将远程数据ftp上传到本地,并存入到mys

页面导航:首页 > 软件编程 > Java编程 > java实现将远程数据ftp上传到本地,并存入到mys

java实现将远程数据ftp上传到本地,并存入到mys

来源: 作者: 时间:2016-01-18 15:52 【

1、Configpackage com.lianlife.sync;import java.text.SimpleDateFormat;import java.util.Date;public class Config {public static final String ftpPath=/PIftp/Yzps/ps001/ps;//public static...
1、Config
package com.lianlife.sync;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Config {
public static final String ftpPath="/PIftp/Yzps/ps001/ps";
//public static final String ftpPath="/PIftp/test01/ps";
public static final String c1 = "17:30:00";
public static final  String c2 = "17:29:00";
public static final String ftpIP = "10.20.28.138";
public static final int ftpPort = 21;
public static final String ftpuser = "ftpuser";
public static final String ftpassword = "ftpuser";
//public static String localDirPath="H:\\yx1\\yq\\ps20150309";
public static String localDirPath="I:\\影像2\\ps2015030923";
public static String date = "20040901";
public static String date2 = "20150926";
public static final String url = "jdbc:://10.20.28.138:3306/mysql";
public static final String driver = "com.mysql.jdbc.Driver";
public static final String user = "root";
public static final String password = "123";
public static boolean isUploadTimePeriod()
{
SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
String timenow = df.format(new Date());
if (timenow.compareTo(Config.c1) > 0
|| timenow.compareTo(Config.c2) < 0){
return true;
}
return false ;
}
}
2、DbUtil
package com.lianlife.sync;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class DbUtil {
public static Connection getConnection()
{
       try {
       Class.forName(Config.driver);//指定连接类型
} catch (Throwable e) {
throw new RuntimeException(e);
}
       
try {
return DriverManager.getConnection(Config.url, Config.user, Config.password);//获取连接
} catch (Throwable e) {
e.printStackTrace();
try {
return DriverManager.getConnection(Config.url, Config.user, Config.password);//获取连接
} catch (Throwable e2) {
e2.printStackTrace();
try {
return DriverManager.getConnection(Config.url, Config.user, Config.password);//获取连接
} catch (Throwable e3) {
throw new RuntimeException(e3);
}
}
}
}
public static  void close(Connection c)
{
if(c!=null)
{
try {
c.close();
} catch (Throwable e) {
 
e.printStackTrace();
}
}
}
public static  void close(PreparedStatement c)
{
if(c!=null)
{
try {
c.close();
} catch (Throwable e) {
 
e.printStackTrace();
}
}
}
public static  void close(ResultSet c)
{
if(c!=null)
{
try {
c.close();
} catch (Throwable e) {
 
e.printStackTrace();
}
}
}
}

 

Tags:

文章评论

最 近 更 新
热 点 排 行
Js与CSS工具
代码转换工具

<