Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <table>
- <column>ID</column>
- <datatype>COUNTER</datatype>
- <column>FirstName</column>
- <datatype>VARCHAR</datatype>
- <column>LastName</column>
- <datatype>VARCHAR</datatype>
- <column>Salary</column>
- <datatype>CURRENCY</datatype>
- <column>SSN</column>
- <datatype>INTEGER</datatype>
- </table>
- <!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
- <etl>
- <connection id="db1" url="jdbc:odbc:TestDB" driver="scriptella.driver.odbc.Driver" user="Dzmitry" password="a"/>
- <connection id="db2" url="jdbc:odbc:PostgreSQLconnector" driver="scriptella.driver.odbc.Driver" classpath="postgresql.jar" user="Dzmitry" password="a"/>
- <connection id="script" driver="script"/>
- <connection id="java" driver="scriptella.driver.janino.Driver"/>
- <connection id="log" driver="text"/>
- <!-- doesn't work
- <script connection-id="db2" new-tx="true" if="create_databases">
- CREATE DATABASE testDB;
- </script>
- -->
- <query connection-id="db1">
- SELECT * FROM GenInfo;
- <script connection-id="script">
- java.lang.System.out.println("Processing row number " + rownum + " ");
- </script>
- <script connection-id="log">
- ${FirstName}, ${LastName}, ${Salary}, ${SSN}
- </script>
- </query>
- <query connection-id="java">
- import javax.xml.parsers.*;
- import javax.xml.xpath.*;
- import java.io.*;
- import org.w3c.dom.Document;
- import org.xml.sax.*;
- DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder docBuilder = dbFactory.newDocumentBuilder();
- File file = new File("tableschema.xml");
- Document document = docBuilder.parse(file);
- XPathFactory xpFactory = XPathFactory.newInstance();
- XPath xPath = xpFactory.newXPath();
- int numberOfColumns = Integer.parseInt(xPath.evaluate("count(/table/column)", document));
- for(int i = 1; i <= numberOfColumns; i++){ // does not take less than sign
- System.out.print("Column name " + i + ": " + xPath.evaluate("/table/column[" + i + "]", document));
- System.out.println("tData type " + i + ": " + xPath.evaluate("/table/datatype[" + i + "]", document));
- }
- </query>
- </etl>
- driver="scriptella.driver.odbc.Driver"
- <connection driver="postgresql" url="jdbc:postgresql://localhost:5432/DATABASENAME" user="username" password="password">
- </connection>
- <connection connection-id="db2" driver="postgresql" url="jdbc:postgresql://localhost:5432/DATABASENAME" user="Dzmitry" password="a" classpath="postgresql.jar">
- </connection>
- <script connection-id="db2">
- CREATE TABLE distributors (
- did integer PRIMARY KEY,
- name varchar(40)
- );
- </script>
- <!-- Connection for just for creating a database -->
- <connection connection-id="db2_init" driver="postgresql" url="jdbc:postgresql://localhost:5432/template1" user="postgres" password="postgres" classpath="postgresql.jar">
- </connection>
- <!-- Connection for DDL and data statements. Needs to be lazy-init=true -->
- <connection connection-id="db2_tables" driver="postgresql" lazy-init="true" url="jdbc:postgresql://localhost:5432/testDB" user="Dzmitry" password="a" classpath="postgresql.jar">
- </connection>
- <script connection-id="db2_init" if="create_databases">
- CREATE DATABASE testDB;
- </script>
- <script connection-id="db2_tables" if="create_schema">
- CREATE TABLE distributors (
- did integer PRIMARY KEY,
- name varchar(40)
- );
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement