如何在Scriptella etl中使用janino脚本?

时间:2013-04-19 11:21:09

标签: etl scriptella janino

我有一个Scriptella etl文件,我解析csv文件并使用示例janino脚本。我总是得到一个例外,没有找到scriptella的驱动程序,虽然我在libs文件夹中有它。

etl.xml

<!DOCTYPE etl SYSTEM "http://scriptella.javaforge.com/dtd/etl.dtd">
<etl>
<description>
    Queries CSV data from from file and store the results in a DB and other CSV file.
</description>
<connection id="in" driver="csv" url="input.csv"/>
 <connection id="out" driver="csv" url="output.csv">
  #Use empty quote to turn off quoting
    quote=
</connection>
<connection id="java" driver="janino" classpath="../lib/janino.jar"/>
   <script connection-id="out"><!--Writing header if necessary-->
   Name,Age,VIP
   </script>
<query connection-id="in">
    <!--Empty CSV query means select all-->
    <script connection-id="java">
      import java.io.*;
       String ntteCode;
    Object o = get("Age");
    if (o == null)
        ntteCode = "";
    else
        ntteCode = o.toString().trim();
        system.out.println("-----------"+ntteCode);
    </script>
</query>
</etl>

以下是我从命令提示符运行etl.xml时遇到的异常。

E:\scriptella-1.0>java -jar scriptella.jar jstack_etl.xml
Apr 19, 2013 4:44:07 PM <INFO> Execution Progress.Initializing properties: 1%
Apr 19, 2013 4:44:07 PM <INFO> Execution Progress.Connection id=in, CsvConnection,            Dialect{CSV 1.0} registered: 2%
Apr 19, 2013 4:44:07 PM <INFO> Execution Progress.Connection id=out, CsvConnection,   Dialect{CSV 1.0} registered: 3%
Apr 19, 2013 4:44:07 PM <SEVERE> Script E:\scriptella-1.0\jstack_etl.xml execution failed.
Unable to initialize driver for ConnectionParameters{properties={}, url='null',   user='null', password='null', schema='null', catalog='null'}
:Unable to instantiate driver for class scriptella.driver.janino.Driver
Janino provider exception: Janino not found on the class path. Check if connection    classpath attribute points to janino.jar
Error codes: []
Driver exception: java.lang.ClassNotFoundException: org.codehaus.janino.ScriptEvaluator

1 个答案:

答案 0 :(得分:0)

您需要在此处下载janino驱动程序: http://dist.codehaus.org/janino/changelog.html

将以下库复制到scriptella / lib目录:

  • 公地compiler.jar
  • janino.jar
  • 公地编译-jdk.jar

尝试使用bin目录中的脚本启动scriptella:

  • scriptella.bat
  • scriptella.sh

此脚本将库添加到类路径中。 您也可以使用以下命令手动添加库:

java -classpath lib/commons-compiler.jar;lib/janino.jar;lib/commons-compiler-jdk.jar -jar scriptella.jar jstack_etl.xml