dad96c62e5fb26957fc0065ac09a6f74f6926dd0.svn-base 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package com.toolkit.databak;
  2. import java.io.BufferedWriter;
  3. import java.io.File;
  4. import java.io.FileWriter;
  5. import java.util.Vector;
  6. import org.apache.log4j.Logger;
  7. import com.persistence.databak.XmlToTable;
  8. public class XmlDataToTable{
  9. private final static Logger log = Logger.getLogger(XmlDataToTable.class);
  10. /**
  11. * 定义需要生成SQL的XML文件路径
  12. */
  13. private static String xmlPathName = "d:\\abl.xml";
  14. /**
  15. * xml生成的SQL语句写入的文件路径
  16. */
  17. private static String sqlfile = "d:\\databak.txt";
  18. /**
  19. * @param args
  20. */
  21. public static void main(String[] args) {
  22. try {
  23. Vector<String> sqlvec = XmlToTable.creatSQLDLL(xmlPathName);
  24. File ff = new File(sqlfile);
  25. ff.createNewFile();
  26. FileWriter fw = new FileWriter(ff);
  27. BufferedWriter bw = new BufferedWriter(fw);
  28. for (int i = 0; i < sqlvec.size(); i++) {
  29. String sql = sqlvec.get(i) + ";";;
  30. // log.info(sql);
  31. bw.write(sql, 0, sql.length());
  32. bw.newLine();
  33. }
  34. log.info("sql语句成功生成到:" + sqlfile);
  35. bw.close();
  36. fw.close();
  37. } catch (Exception e) {
  38. e.printStackTrace();
  39. }
  40. }
  41. }