欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

读excel文件生成sql

程序员文章站 2022-03-01 20:26:09
...
import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class StringToolSqlFormatter {

    private static final String SQL_1 = "update t_call_data set DECISION_COMPLETE_TYPE='BATCH_DECISION_COMPILTE' where REGISTER_ID=%s and DATE_FORMAT(IMPORT_TIME,'%Y-%m-%e')=" +
            "DATE_FORMAT(IMPORT_TIME,'%s')";


    public static void main(String[] args) {
        try {
            FileReader reader = new FileReader("F:\\工作间\\电销\\归档\\新建文件夹\\kkd.csv");
BufferedReader br = new BufferedReader(reader);
FileWriter writer = new FileWriter("F:\\工作间\\电销\\归档\\新建文件夹\\output_kkd.txt");
BufferedWriter bw = new BufferedWriter(writer);


String str = null;
//            List<String> ls = new ArrayList<>();

while ((str = br.readLine()) != null) {
                String sql = "update t_call_data set DECISION_COMPLETE_TYPE='BATCH_DECISION_COMPILTE' where REGISTER_ID=";
String[] arr = str.split(",");
String firstParam = arr[0];
String secondParam = arr[1].substring(0,10);
sql = sql+ firstParam + " and DATE_FORMAT(IMPORT_TIME,'%Y-%m-%e')='"+ secondParam +"'";
sql = sql + " and IMPORT_TIME between '2022-01-01 00:00:00' and '2022-01-27 23:59:59'"+";\r\n";
System.out.println(sql);
bw.write(sql);
}
            br.close();
reader.close();
bw.close();
} catch (IOException e) {
            e.printStackTrace();
} finally {

        }


    }

}