All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mg.common.tools.SyncDBDataContext Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
package com.mg.common.tools;

import org.apache.commons.lang3.StringUtils;

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

/**
 * 用来同步数据的上下文对象,存放大量中间变量

 */
public class SyncDBDataContext {
    public String localDBip;
    public String localDBSchema;// = properties.getProperty("connection.schema");//"jdbc:mysql://172.16.90.114:3306/shaoxing?useUnicode=true&characterEncoding=utf-8";
    public String localDBUsername;// = properties.getProperty("connection.username"); //"root";
    public String localDBPassword;// = properties.getProperty("connection.password"); //"123456";
    public String sourceDBip;// = properties.getProperty("source.connection.ip");//"jdbc:mysql://172.16.90.114:3306/shaoxing?useUnicode=true&characterEncoding=utf-8";
    public String sourceDBSchema;// = properties.getProperty("source.connection.schema");//"jdbc:mysql://172.16.90.114:3306/shaoxing?useUnicode=true&characterEncoding=utf-8";
    public String sourceDBUsername;// = properties.getProperty("source.connection.username"); //"root";
    public String sourceDBPassword;// = properties.getProperty("source.connection.password"); //"123456";
    public String mysqldumpCmd;// = properties.getProperty("mysqldump.cmd");// ssh [email protected] mysqldump
    public String mysqlCmd;// = properties.getProperty("mysql.cmd");// ssh [email protected] mysqldump
    public String dumpPath;// = properties.getProperty("mysql.cmd");// ssh [email protected] mysqldump
    public String dumpFilename;// = properties.getProperty("mysql.cmd");// ssh [email protected] mysqldump


    public SyncDBDataContext(Properties properties) {
        localDBip = properties.getProperty("connection.ip");//"jdbc:mysql://172.16.90.114:3306/shaoxing?useUnicode=true&characterEncoding=utf-8";
        localDBSchema = properties.getProperty("connection.schema");//"jdbc:mysql://172.16.90.114:3306/shaoxing?useUnicode=true&characterEncoding=utf-8";
        localDBUsername = properties.getProperty("connection.username"); //"root";
        localDBPassword = properties.getProperty("connection.password"); //"123456";

        sourceDBip = properties.getProperty("source.connection.ip");//"jdbc:mysql://172.16.90.114:3306/shaoxing?useUnicode=true&characterEncoding=utf-8";
        sourceDBSchema = properties.getProperty("source.connection.schema");//"jdbc:mysql://172.16.90.114:3306/shaoxing?useUnicode=true&characterEncoding=utf-8";
        sourceDBUsername = properties.getProperty("source.connection.username"); //"root";
        sourceDBPassword = properties.getProperty("source.connection.password"); //"123456";

        mysqldumpCmd = properties.getProperty("mysqldump.cmd");// ssh [email protected] mysqldump
        mysqlCmd = properties.getProperty("mysql.cmd");// ssh [email protected] mysqldump
        if(StringUtils.isBlank(mysqldumpCmd))
            mysqldumpCmd = "mysqldump";

        dumpPath = properties.getProperty("dump.path");// ssh [email protected] mysqldump
        if(StringUtils.isBlank(dumpPath))
            dumpPath = "/tmp";

        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
        dumpFilename = String.format("%s-%s-%s.sql",
                sdf.format(new Date()),
                sourceDBip.replace(".", "-"),
                sourceDBSchema
        );
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy