Guest User

Untitled

a guest
Jun 12th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. <? xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
  3. <etl>
  4. <connection id = "in" driver="janino"/>
  5. <connection id = "out"
  6. driver="scriptella.driver.postgresql.Driver"
  7. url="jdbc:postgresql://localhost:32768/postgres"
  8. schema="fias"
  9. user="postgres"
  10. password="postgres">
  11. autocommit.size=100
  12. </connection>
  13.  
  14. <query connection-id="in">
  15. import javax.xml.parsers.SAXParser;
  16. import javax.xml.parsers.SAXParserFactory;
  17. import org.xml.sax.Attributes;
  18. import org.xml.sax.SAXException;
  19. import org.xml.sax.helpers.DefaultHandler;
  20.  
  21. SAXParserFactory factory = SAXParserFactory.newInstance();
  22. SAXParser saxParser = factory.newSAXParser();
  23.  
  24. DefaultHandler handler = new DefaultHandler() {
  25. boolean isObject = false;
  26. int nodeCnt = 0;
  27. int recordCnt = 0;
  28. public void startElement(String uri, String localName, String qName, Attributes attr) throws SAXException
  29. {
  30. String names = "";
  31. String values = "";
  32. System.out.print("rnames: " + names);
  33.  
  34. if (nodeCnt < 1)
  35. { // skip first node
  36. nodeCnt++;
  37. } else {
  38.  
  39.  
  40. int attrCnt = attr.getLength();
  41. for (int i = 0; i & lt; attrCnt; i++) {
  42.  
  43.  
  44. names += attr.getQName(i) + ",";
  45. values += "'" + attr.getValue(i).replaceAll("'", "''") + "',";
  46.  
  47. System.out.print("rnames: " + names);
  48. }
  49.  
  50. names = names.substring(0, names.length() - 1);
  51. values = values.substring(0, values.length() - 1);
  52. set("sql_names", names);
  53. set("sql_values", values);
  54. < script connection - id = "out" >
  55. INSERT INTO addrobj($sql_names) VALUES($sql_values);
  56. </ script >
  57. next();
  58.  
  59. recordCnt++;
  60. System.out.print("rprocessed: " + recordCnt);
  61. }
  62. }
  63. };
  64. System.out.println("nnnConverting...");
  65. saxParser.parse("C:UsersdvproDownloadsfias_xmlAS_ADDROBJ_20180607_3c59c5c3-e827-455f-a8dd-32eb9d8f92d6.XML", handler);
  66. </query>
  67. </etl>
  68.  
  69. 12.06.2018 21:05:49 <INFO> Execution Progress.Initializing properties: 1%
  70. 12.06.2018 21:05:50 <INFO> Execution Progress.Initialized connection id=in, JaninoConnection, Dialect{ Janino 2.56}, properties {}: 3%
  71. 12.06.2018 21:05:50 <INFO> Execution Progress.Initialized connection id =out, JdbcConnection{ org.postgresql.jdbc.PgConnection}, Dialect{PostgreSQL 10.4 (Debian 10.4-2.pgdg90+1)}, properties {autocommit.size=100}: 5%
  72. 12.06.2018 21:05:50 <INFO> Execution Progress./etl/query[1] prepared: 10%
  73. 12.06.2018 21:05:50 <INFO> Registered JMX mbean: scriptella:type= etl, url= "file:/C:/sql/scriptella-1.1/bin/etl.xml"
  74.  
  75. Converting...
  76. 12.06.2018 21:05:50 <WARNING> Unable to rollback transaction for connection JaninoConnection: Transactions are not supported by JaninoConnection
  77. 12.06.2018 21:05:50 <SEVERE> Script C:sqlscriptella-1.1binetl.xml execution failed.
  78. Location: /etl/query[1]
  79. Janino provider exception: Query execution failed due to exception
  80. Error codes: []
  81. Driver exception: java.net.MalformedURLException: unknown protocol: c
  82. PS C:sqlscriptella-1.1
  83.  
  84. saxParser.parse("file:///C:/Users/dvpro/Downloads/fias_xml/AS_ADDROBJ_20180607_3c59c5c3-e827-455f-a8dd-32eb9d8f92d6.XML", handler);
Add Comment
Please, Sign In to add comment