0

我有一个 Scriptella etl 文件,我在其中解析 csv 文件并使用示例 janino 脚本。尽管我在 libs 文件夹中找到了未找到 scriptella 的驱动程序,但我总是遇到异常。

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
4

1 回答 1

1

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

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

  • commons-compiler.jar
  • janino.jar
  • commons-compiler-jdk.jar

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

  • 脚本文件
  • 脚本文件

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

java -classpath lib/commons-compiler.jar;lib/janino.jar;lib/commons-compiler-jdk.jar -jar scriptella.jar jstack_etl.xml
于 2013-04-21T17:17:28.263 回答