Java implements the upload of Remote Data Over ftp to the local computer and coexist in the mysql database.
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 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; pub Lic static final String ftpuser = "ftpuser"; public static final String ftpassword = "ftpuser"; // public static String localDirPath = "H: \ yx1 \ yq \ ps20150309 "; public static String localDirPath =" I: \ Image 2 \ ps2015030923 "; public static String date =" 20040901 "; public static String date2 = "20150926"; public static final String url = "jdbc: mysql: // 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. DbUtilpackage com. lianlife. sync; import java. SQL. C Onnection; import java. SQL. driverManager; import java. SQL. preparedStatement; import java. SQL. resultSet; public class DbUtil {public static Connection getConnection () {try {Class. forName (Config. driver); // specify the connection type} catch (Throwable e) {throw new RuntimeException (e);} try {return DriverManager. getConnection (Config. url, Config. user, Config. password); // get connection} catch (Throwable e) {e. printStackTrace (); try {ret Urn DriverManager. getConnection (Config. url, Config. user, Config. password); // get connection} catch (Throwable e2) {e2.printStackTrace (); try {return DriverManager. getConnection (Config. url, Config. user, Config. password); // get Connection} 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 ();}}}}