See: Description
Class | Description |
---|---|
BindingsParametersCallback |
Bindings implementation for
integration into Scriptella execution environment. |
Driver |
Scriptella bridge for the JSR 223: Scripting for the Java Platform.
|
MissingQueryNextCallDetector |
CRQ-12257.
|
NashornBindingsParametersCallback |
Implementation of
Bindings for Java 8 JavaScript engine "Nashorn". |
ParametersCallbackMap |
Map implementation of ParametersCallback for
integration into Scriptella execution environment. |
ScriptConnection |
Scriptella connection adapter for the JSR 223: Scripting for the Java Platform.
|
Exception | Description |
---|---|
ScriptProviderException |
Thrown to indicate an error in scripting engine.
|
The driver relies on javax.script package from Java SE 6. The default language expected by the driver is JavaScript which is bundled with JRE.
Driver class: | scriptella.driver.script.Driver |
URL: | URL of the file to read from and send output to. URIs are resolved relative to a script file.
If url is not specified console (System.in/out ) is used. |
Runtime dependencies: | Java SE 6 is required. Additional dependencies are specific to a scripting language. |
Name | Description | Required |
---|---|---|
language | Language used in scripts and queries. | No, the default language is JavaScript . |
encoding | Specifies charset encoding of a character stream specified by an url connection parameter. | No, the system default encoding is used. |
Scripts and queries can reference variables from ancestor elements. Declared variables are exposed to nested elements.
Implicit variable query
is available in <query> elements. This variable
should be used to produce a result set:
<query><![CDATA[
var v1 = 'This variable is visible in a child script';
for (var i = 0; i < 10; i++) {
query.next(); // Triggers execution of a child script.
}]]>
<script>
......
v2 = v1 + '!';
......
</script>
</query>
See ParametersCallbackMap class Javadoc for more details.
<connection id="script" driver="script"/>
<connection id="out" driver="oracle" url="jdbc:oracle:thin:@localhost:1521:DB"/>
<connection id="log" driver="script" url="log.txt"/>
<query connection-id="script">
<![CDATA[
for (var i = 0; i < 10; i++) {
login = 'login' + i;
//You can instantiate Java objects and invoke static methods
var now = new java.sql.Timestamp(java.lang.System.currentTimeMillis());
query.next(); //Executes a child script element
}]]>
<!-- Inserts a parameterized row into a database -->
<script connection-id="out">
INSERT INTO Table(ID, Login, Login_Time) VALUES (?i, ?login, ?now);
</script>
<!-- Logs the message using MessageFormat class and parent context variables -->
<script connection-id="log">
// create Java String array of 2 elements
var a = java.lang.reflect.Array.newInstance(java.lang.Object, 2)
a[0] = now;a[1] = i;
println(format.format(a));
>/script>
</query>
Copyright © Copyright 2006-2019 The Scriptella Project Team.