-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtutorial.html
415 lines (400 loc) · 15 KB
/
tutorial.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta content="Apache Forrest" name="Generator">
<meta name="Forrest-version" content="0.9">
<meta name="Forrest-skin-name" content="pelt">
<title>Two Minute Tutorial</title>
<link type="text/css" href="skin/basic.css" rel="stylesheet">
<link media="screen" type="text/css" href="skin/screen.css" rel="stylesheet">
<link media="print" type="text/css" href="skin/print.css" rel="stylesheet">
<link type="text/css" href="skin/profile.css" rel="stylesheet">
<script src="skin/getBlank.js" language="javascript" type="text/javascript"></script><script src="skin/getMenu.js" language="javascript" type="text/javascript"></script><script src="skin/fontsize.js" language="javascript" type="text/javascript"></script>
<link rel="shortcut icon" href="favicon.ico">
</head>
<body onload="init()">
<script type="text/javascript">ndeSetTextSize();</script>
<div id="top">
<!--+
|header
+-->
<div class="header">
<!--+
|start group logo
+-->
<div class="grouplogo">
<a href="http://scriptella.org"></a>
</div>
<!--+
|end group logo
+-->
<!--+
|start Project Logo
+-->
<div class="projectlogo">
<a href="http://scriptella.org/"><img class="logoImage" alt="Scriptella" src="images/site-logo.png" title="Open Source ETL and Script Execution Tool."></a>
</div>
<!--+
|end Project Logo
+-->
<!--+
|start Search
+-->
<div class="searchbox">
<form action="http://www.google.com/search" method="get" class="roundtopsmall">
<input value="scriptella.org" name="sitesearch" type="hidden"><input onFocus="getBlank (this, 'Search the site with google');" size="25" name="q" id="query" type="text" value="Search the site with google">
<input name="Search" value="Search" type="submit">
</form>
</div>
<!--+
|end search
+-->
<!--+
|start Tabs
+-->
<ul id="tabs">
<li class="current">
<a class="selected" href="index.html">Home</a>
</li>
<li>
<a class="unselected" href="reference/index.html">Reference</a>
</li>
<li>
<a class="unselected" href="howto/migrate-from-ant.html">How-Tos</a>
</li>
</ul>
<!--+
|end Tabs
+-->
</div>
</div>
<div id="main">
<div id="publishedStrip">
<!--+
|start Subtabs
+-->
<div id="level2tabs"></div>
<!--+
|end Endtabs
+-->
<script type="text/javascript"><!--
document.write("Last Published: " + document.lastModified);
// --></script>
</div>
<!--+
|breadtrail
+-->
<div class="breadtrail">
<script src="skin/breadcrumbs.js" language="JavaScript" type="text/javascript"></script>
</div>
<!--+
|start Menu, mainarea
+-->
<!--+
|start Menu
+-->
<div id="menu">
<div onclick="SwitchMenu('menu_1.1', 'skin/')" id="menu_1.1Title" class="menutitle">Scriptella</div>
<div id="menu_1.1" class="menuitemgroup">
<div class="menuitem">
<a href="index.html" title="About Scriptella">About</a>
</div>
<div class="menuitem">
<a href="license.html" title="Scriptella License">License</a>
</div>
<div class="menuitem">
<a href="changes.html">Change History</a>
</div>
<div class="menuitem">
<a href="support.html" title="Scriptella Project Support">Support</a>
</div>
<div class="menuitem">
<a href="download.html" title="Download Scriptella Binary and Source Distribution">Download</a>
</div>
<div class="menuitem">
<a href="links.html" title="Scriptella Related Links">Links</a>
</div>
</div>
<div onclick="SwitchMenu('menu_selected_1.2', 'skin/')" id="menu_selected_1.2Title" class="menutitle" style="background-image: url('skin/images/chapter_open.gif');">Getting Started</div>
<div id="menu_selected_1.2" class="selectedmenuitemgroup" style="display: block;">
<div class="menupage">
<div class="menupagetitle">Two Minute Tutorial</div>
</div>
<div class="menuitem">
<a href="faq.html" title="Frequently Asked Questions">FAQ</a>
</div>
</div>
<div onclick="SwitchMenu('menu_1.3', 'skin/')" id="menu_1.3Title" class="menutitle">Documentation</div>
<div id="menu_1.3" class="menuitemgroup">
<div class="menuitem">
<a href="reference/index.html" title="Scriptella Reference Documentation">Reference Documentation</a>
</div>
<div class="menuitem">
<a href="reference/drivers.html">Drivers Matrix</a>
</div>
<div class="menuitem">
<a href="docs/api/index.html">API Docs</a>
</div>
<div class="menuitem">
<a href="docs/dtd/index.html">DTD Reference</a>
</div>
<div onclick="SwitchMenu('menu_1.3.5', 'skin/')" id="menu_1.3.5Title" class="menutitle">How-Tos</div>
<div id="menu_1.3.5" class="menuitemgroup">
<div class="menuitem">
<a href="howto/migrate-from-ant.html">Migrate from Ant SQL Task</a>
</div>
<div class="menuitem">
<a href="howto/initialize-database.html">Automated Database Initialization</a>
</div>
</div>
</div>
<div id="credit">
<!-- TODO Additional Links/Tags Go Here -->
</div>
<div id="roundbottom">
<img style="display: none" class="corner" height="15" width="15" alt="" src="skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
<!--+
|alternative credits
+-->
<div id="credit2"></div>
</div>
<!--+
|end Menu
+-->
<!--+
|start content
+-->
<div id="content">
<div title="Portable Document Format" class="pdflink">
<a class="dida" href="tutorial.pdf"><img alt="PDF -icon" src="skin/images/pdfdoc.gif" class="skin"><br>
PDF</a>
</div>
<div class="trail">Font size:
<input value="Reset" class="resetfont" title="Reset text" onclick="ndeSetTextSize('reset'); return false;" type="button">
<input value="-a" class="smallerfont" title="Shrink text" onclick="ndeSetTextSize('decr'); return false;" type="button">
<input value="+a" class="biggerfont" title="Enlarge text" onclick="ndeSetTextSize('incr'); return false;" type="button">
</div>
<h1>Two Minute Tutorial</h1>
<div id="front-matter">
<div id="minitoc-area">
<ul class="minitoc">
<li>
<a href="#Installation">Installation</a>
</li>
<li>
<a href="#Use+Scriptella+as+Ant+Task">Use Scriptella as Ant Task</a>
</li>
<li>
<a href="#Command-Line+Execution">Command-Line Execution</a>
</li>
<li>
<a href="#Executing+ETL+Files+from+Java">Executing ETL Files from Java</a>
</li>
<li>
<a href="#Examples">Examples</a>
<ul class="minitoc">
<li>
<a href="#Copy+table+to+another+database">Copy table to another database</a>
</li>
<li>
<a href="#Working+with+BLOBs">Working with BLOBs</a>
</li>
<li>
<a href="#Supporting+several+SQL+dialects">Supporting several SQL dialects</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<a name="Installation"></a>
<h2 class="boxed">Installation</h2>
<div class="section">
<ul>
<li>
<a href="download.html">Download</a> Scriptella binary distribution.</li>
<li>Unpack it and add a <SCRIPTELLA_DIR>/bin to a system <span class="codefrag">PATH</span> variable.
<p>Use <span class="codefrag">set PATH=%PATH%;SCRIPTELLA_DIR\bin</span> for Windows and
<span class="codefrag">export PATH=${PATH}:SCRIPTELLA_DIR/bin</span> for Unix.</p>
</li>
<li>Check if JRE has been installed correctly by running java -version.</li>
<li>
<em>Optional step:</em> Put JDBC drivers required by your scripts to <SCRIPTELLA_DIR>/lib directory
or directly specify classpath attribute in script connection elements.</li>
</ul>
</div>
<a name="Use+Scriptella+as+Ant+Task"></a>
<h2 class="boxed">Use Scriptella as Ant Task</h2>
<div class="section">
<p>In order to use Scriptella as Ant task you will need the following taskdef declaration:</p>
<pre class="code"><taskdef resource="antscriptella.properties" classpath="/path/to/scriptella.jar[;additional_drivers.jar]"/></pre>
<div class="note">
<div class="label">Note</div>
<div class="content">Additional drivers classpath entries are optional. You may directly specify classpath attribute in
a connection XML element declaration. Example:<br>
<span class="codefrag"><connection driver="sybase" classpath="jconn3.jar"/>
</span>
</div>
</div>
<p>Running Scriptella files from Ant is simple:</p>
<pre class="code"><etl/> <!-- Execute etl.xml file in the current directory --></pre>
<p>or</p>
<pre class="code"><etl file="path/to/your/file/> <!-- Execute ETL file from specified location --></pre>
</div>
<a name="Command-Line+Execution"></a>
<h2 class="boxed">Command-Line Execution</h2>
<div class="section">
<p>Just type <span class="codefrag">scriptella</span> to run the file named etl.xml in the current directory.
Alternatively you can use java launcher:</p>
<pre class="code">java -jar scriptella.jar [arguments]</pre>
</div>
<a name="Executing+ETL+Files+from+Java"></a>
<h2 class="boxed">Executing ETL Files from Java</h2>
<div class="section">
<p>It is extremely easy to run Scriptella ETL files from java code.
Just make sure scriptella.jar is on classpath and use any of the following methods to execute an ETL file:</p>
<pre class="code">
EtlExecutor.newExecutor(new File("etl.xml")).execute(); //Execute etl.xml file
EtlExecutor.newExecutor(getClass().getResource("etl.xml")).execute(); //Execute etl.xml file loaded from classpath
EtlExecutor.newExecutor(
servletContext.getResource("/WEB-INF/db/init.etl.xml")).execute(); //Execute init.etl.xml file from web application WEB-INF directory</pre>
<p>See <a href="../docs/api/scriptella/execution/EtlExecutor.html">EtlExecutor Javadoc</a>
for more details on how to execute ETL files from Java code.
</p>
</div>
<a name="Examples"></a>
<h2 class="boxed">Examples</h2>
<div class="section">
<p>For a quick start type <span class="codefrag">scriptella -t</span> to create a template etl.xml file.</p>
<a name="Copy+table+to+another+database"></a>
<h3 class="boxed">Copy table to another database</h3>
<div style="text-align: center;">
<img class="figure" alt="Migration of table records" src="./images/table_copy.png"></div>
<p>Assume Database #1 contains Table Product with id, category and name columns. The following script
copies software products from this table to Database #2. Additionally Name column is changed to Product_Name.</p>
<p>etl.xml:</p>
<pre class="code">
<etl>
<connection id="db1" url="jdbc:database1:sample" user="sa" password="" classpath="external.jar"/>
<connection id="db2" url="jdbc:database2:sample" user="sa" password=""/>
<query connection-id="db1">
<!-- Select product from software category in db1-->
SELECT * FROM Product WHERE category='software';
<!-- for each row execute a script -->
<script connection-id="db2">
<!-- Insert all selected products to db2
use ? to reference properties, columns or ?{expressions}-->
INSERT INTO Product(id, category, product_name) values (?id, ?{category}, ?name);
</script>
</query>
</etl>
</pre>
<a name="Working+with+BLOBs"></a>
<h3 class="boxed">Working with BLOBs</h3>
<div style="text-align: center;">
<img class="figure" alt="Inserting BLOB content from URL" src="./images/blob_insert.png"></div>
<p>The following sample initializes table of music tracks. Each track has a DATA field containing
a file loaded from an external location. File song1.mp3 is stored in the same directory as etl.xml and song2.mp3
is loaded through the web.</p>
<p>etl.xml:</p>
<pre class="code">
<etl>
<connection url="jdbc:hsqldb:file:tracks" user="sa" password=""/>
<script>
CREATE TABLE Track (
ID INT,
ALBUM_ID INT,
NAME VARCHAR(100),
DATA LONGVARBINARY
);
<!-- Inserts file with path relative to executed script location -->
insert into Track(id, album_id, name, data) values
(1, 1, 'Song1.mp3', ?{file 'song1.mp3'});
<!-- Inserts file from URL-->
insert into Track(id, album_id, name, data) values
(2, 2, 'Song2.mp3', ?{file 'http://musicstoresample.com/song2.mp3'});
</script>
</etl>
</pre>
<a name="Supporting+several+SQL+dialects"></a>
<h3 class="boxed">Supporting several SQL dialects</h3>
<p><dialect> element allows including vendor specific content.
The following example creates database schema for Oracle/HSQLDB or MySql
depending on a selected driver:</p>
<pre class="code">
<etl>
<properties><!-- Load external properties -->
<include href="etl.properties"/>
</properties>
<connection url="$url" user="$user"
password="$password" classpath="$classpath"/>
<script>
-- In this example dialects are used to
-- include different DDLs for data types:
-- Example: oracle-schema.sql for Oracle
<dialect name="hsql"> <!-- Regular expressions syntax supported-->
<include href="hsqldb-schema.sql"/>
</dialect>
<dialect name="oracle">
<include href="oracle-schema.sql"/>
</dialect>
<dialect name="mysql">
<include href="mysql-schema.sql"/>
</dialect>
-- SQL92 inserts - no need to use dialects
INSERT INTO Product(id, category, product_name)
VALUES (1, 'ETL', 'Scriptella ETL');
INSERT INTO Product(id, category, product_name)
VALUES (2, 'Development', 'Java SE 6');
</script>
</etl></pre>
<div class="note">
<div class="label">Note</div>
<div class="content">
See <a href="https://github.com/scriptella/scriptella-examples">Scriptella examples on GitHub</a>
or <a href="download.html">download</a> Scriptella examples distribution.
</div>
</div>
</div>
</div>
<!--+
|end content
+-->
<div class="clearboth"> </div>
</div>
<div id="footer">
<!--+
|start bottomstrip
+-->
<div class="lastmodified">
<script type="text/javascript"><!--
document.write("Last Published: " + document.lastModified);
// --></script>
</div>
<div class="copyright">
Copyright ©
2006-2019 <a href="http://scriptella.org/license.html">The Scriptella Project Team.</a>
</div>
<div id="feedback">
Send feedback about the website to:
<a id="feedbackto" href="mailto:[email protected]?subject=Feedback%C2%A0tutorial.html">Fyodor Kupolov</a>
</div>
<!--+
|end bottomstrip
+-->
</div>
<!-- Start of StatCounter Code for Default Guide -->
<script type="text/javascript">
var sc_project=10775960;
var sc_invisible=1;
var sc_security="53eaed1c";
var scJsHost = (("https:" == document.location.protocol) ?
"https://secure." : "http://www.");
document.write("<sc"+"ript type='text/javascript' src='" +
scJsHost+
"statcounter.com/counter/counter.js'></"+"script>");
</script>
<!-- End of StatCounter Code for Default Guide -->
</body>
</html>