Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <? xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
- <etl>
- <connection id = "in" driver="janino"/>
- <connection id = "out"
- driver="scriptella.driver.postgresql.Driver"
- url="jdbc:postgresql://localhost:32768/postgres"
- schema="fias"
- user="postgres"
- password="postgres">
- autocommit.size=100
- </connection>
- <query connection-id="in">
- import javax.xml.parsers.SAXParser;
- import javax.xml.parsers.SAXParserFactory;
- import org.xml.sax.Attributes;
- import org.xml.sax.SAXException;
- import org.xml.sax.helpers.DefaultHandler;
- SAXParserFactory factory = SAXParserFactory.newInstance();
- SAXParser saxParser = factory.newSAXParser();
- DefaultHandler handler = new DefaultHandler() {
- boolean isObject = false;
- int nodeCnt = 0;
- int recordCnt = 0;
- public void startElement(String uri, String localName, String qName, Attributes attr) throws SAXException
- {
- String names = "";
- String values = "";
- System.out.print("rnames: " + names);
- if (nodeCnt < 1)
- { // skip first node
- nodeCnt++;
- } else {
- int attrCnt = attr.getLength();
- for (int i = 0; i & lt; attrCnt; i++) {
- names += attr.getQName(i) + ",";
- values += "'" + attr.getValue(i).replaceAll("'", "''") + "',";
- System.out.print("rnames: " + names);
- }
- names = names.substring(0, names.length() - 1);
- values = values.substring(0, values.length() - 1);
- set("sql_names", names);
- set("sql_values", values);
- < script connection - id = "out" >
- INSERT INTO addrobj($sql_names) VALUES($sql_values);
- </ script >
- next();
- recordCnt++;
- System.out.print("rprocessed: " + recordCnt);
- }
- }
- };
- System.out.println("nnnConverting...");
- saxParser.parse("C:UsersdvproDownloadsfias_xmlAS_ADDROBJ_20180607_3c59c5c3-e827-455f-a8dd-32eb9d8f92d6.XML", handler);
- </query>
- </etl>
- 12.06.2018 21:05:49 <INFO> Execution Progress.Initializing properties: 1%
- 12.06.2018 21:05:50 <INFO> Execution Progress.Initialized connection id=in, JaninoConnection, Dialect{ Janino 2.56}, properties {}: 3%
- 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%
- 12.06.2018 21:05:50 <INFO> Execution Progress./etl/query[1] prepared: 10%
- 12.06.2018 21:05:50 <INFO> Registered JMX mbean: scriptella:type= etl, url= "file:/C:/sql/scriptella-1.1/bin/etl.xml"
- Converting...
- 12.06.2018 21:05:50 <WARNING> Unable to rollback transaction for connection JaninoConnection: Transactions are not supported by JaninoConnection
- 12.06.2018 21:05:50 <SEVERE> Script C:sqlscriptella-1.1binetl.xml execution failed.
- Location: /etl/query[1]
- Janino provider exception: Query execution failed due to exception
- Error codes: []
- Driver exception: java.net.MalformedURLException: unknown protocol: c
- PS C:sqlscriptella-1.1
- 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