123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package com.toolkit.databak;
- import java.io.BufferedWriter;
- import java.io.File;
- import java.io.FileWriter;
- import java.util.Vector;
- import org.apache.log4j.Logger;
- import com.persistence.databak.XmlToTable;
- public class XmlDataToTable{
- private final static Logger log = Logger.getLogger(XmlDataToTable.class);
- /**
- * 定义需要生成SQL的XML文件路径
- */
- private static String xmlPathName = "d:\\abl.xml";
- /**
- * xml生成的SQL语句写入的文件路径
- */
- private static String sqlfile = "d:\\databak.txt";
- /**
- * @param args
- */
- public static void main(String[] args) {
- try {
- Vector<String> sqlvec = XmlToTable.creatSQLDLL(xmlPathName);
- File ff = new File(sqlfile);
- ff.createNewFile();
- FileWriter fw = new FileWriter(ff);
- BufferedWriter bw = new BufferedWriter(fw);
- for (int i = 0; i < sqlvec.size(); i++) {
- String sql = sqlvec.get(i) + ";";;
- // log.info(sql);
- bw.write(sql, 0, sql.length());
- bw.newLine();
- }
- log.info("sql语句成功生成到:" + sqlfile);
- bw.close();
- fw.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
|