mirror of
https://github.com/Wisser/Jailer.git
synced 2026-01-03 00:59:34 -06:00
215 lines
15 KiB
HTML
215 lines
15 KiB
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
|
|
<title>Jailer - API</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
|
|
<meta name="keywords" content="Data Export Tool" />
|
|
<meta name="description" content="data export referential integrity java jdbc dbms" />
|
|
<link rel="stylesheet" type="text/css" href="styles.css" />
|
|
<link rel="shortcut icon" href="favicon.ico" />
|
|
</head>
|
|
|
|
<body left-margin="0" top-margin="0">
|
|
<div align="left">
|
|
<table style="text-align: left; position: absolute; left: 0pt; top: 0pt;" border="0"
|
|
cellpadding="0" cellspacing="0" height="407" width="100%">
|
|
<tbody>
|
|
<tr>
|
|
<td colspan="2" class="bannerbackground" height="33" width="100%">
|
|
<table border="0" cellpadding="4" cellspacing="0" width="100%">
|
|
<tbody>
|
|
<tr>
|
|
<td><a href="https://github.com/Wisser/Jailer"><img src="logo.png" hspace="10" /></td> <td class="slogan" width="100%"></a>
|
|
|
|
|
|
|
|
<td style="text-align: right; width: 100%;"><table border="0" cellpadding="0" cellspacing="0">
|
|
<tbody>
|
|
<tr>
|
|
<td><a href="https://github.com/Wisser/Jailer"><img src="GitHub-Mark-64px.png" title="GitHub" /></a> </td></tr><tr style="height: 100%;"><td> </td>
|
|
</tr>
|
|
</tbody>
|
|
</table> </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<tr>
|
|
<td colspan="2" class="nav1background" width="100%">
|
|
<b><font color="#FFFFFF"><a href="home.htm" target="_self" class=
|
|
"tlink"> Home </a> <a href="quicktour.htm" target=
|
|
"_self" class="tlink"> Quick Tour </a> <a href=
|
|
"exporting-data.htm" target="_self" class="tlink"> Tutorial </a>
|
|
<a href="data-browsing.html" target="_self" class=
|
|
"tlink"> Data Browser </a> <a class="tlink" href="videos.html" target="_self"> Videos </a> <a href="faq.html" target=
|
|
"_self" class="tlink"> FAQ </a> <a href="api.html"
|
|
target="_self" class="tlinkA"> API </a> <a href=
|
|
"design.htm" target="_self" class="tlink"> Documentation </a>
|
|
<a href=
|
|
"http://sourceforge.net/forum/?group_id=197260" target="_self" class=
|
|
"tlink"> Forum </a> <a href=
|
|
"http://sourceforge.net/project/showfiles.php?group_id=197260" target=
|
|
"_self" class="tlink"> Download </a>
|
|
</font></b></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td colspan="2" class="spacer" width="100%"></td> </tr><tr><td class="lmenucontainer"> </td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="lmenucontainer" height="100%" valign="top" width="14%">
|
|
<div align="center">
|
|
<center>
|
|
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
|
<tbody>
|
|
<tr>
|
|
<td height="6px" width="100%"> </td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</center>
|
|
</div>
|
|
|
|
<ul>
|
|
<li><a href="api.html" target="_self" class="llinkA">API</a> </li>
|
|
</ul>
|
|
|
|
<table border="0" cellpadding="5" cellspacing="0" width="100%">
|
|
<tbody>
|
|
<tr>
|
|
<td class="content2background"><img style=
|
|
"width: 160px; height: 1px;" alt="" src=
|
|
"architecture-Dateien/vgradp.gif" /></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<p> </p>
|
|
</td>
|
|
|
|
<td class="contentbackground" height="418" valign="top" width="86%">
|
|
<div align="right">
|
|
<table border="0" cellpadding="0" cellspacing="0" height="542"
|
|
width="98%">
|
|
<tbody>
|
|
<tr>
|
|
<td class="contentbackground" height="21" width="100%">
|
|
<br /></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="content" height="520" valign="top" width="100%">
|
|
|
|
<big><span style="font-weight: bold;">Application
|
|
Programming Interface<br />
|
|
<br /></span></big> The API provides programmatic access to
|
|
the data export and import functionality.<br />
|
|
<br />
|
|
<br />
|
|
<big><span style=
|
|
"font-weight: bold;">Dependencies</span></big>
|
|
|
|
<ul>
|
|
<li>jailer-engine-<i>version</i>.jar (<a href="https://mvnrepository.com/artifact/io.github.wisser/jailer-engine">MVN-Repository</a>, also included in jailer-<i>version</i>.zip)</li>
|
|
|
|
<ul><li>If you are not using a dependency management system, add the required jar-files in the <i>lib/</i> directory to the class path manually.</li>
|
|
</ul></ul><br />
|
|
<big><span style="font-weight: bold;">Classes</span></big>
|
|
|
|
<ul>
|
|
<li><a href="api/net/sf/jailer/api/Subsetter.html"
|
|
target="_blank">net.sf.jailer.api.Subsetter</a> <br />
|
|
generates a subset of a relational database that respects
|
|
foreign key constraints.</li>
|
|
|
|
<li><a href="api/net/sf/jailer/api/Importer.html" target=
|
|
"_blank">net.sf.jailer.api.Importer</a> <br />
|
|
imports subset data.<br /></li>
|
|
</ul><br />
|
|
<big><span style=
|
|
"font-weight: bold;">Example</span></big><br />
|
|
<br />
|
|
The example is included in the sources. It extracts some data
|
|
from the "demo-scott" database and imports it into another
|
|
database "demo-scott-subset".<br />
|
|
|
|
<ul>
|
|
|
|
<li>Source<br />
|
|
<pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> APIExample <span style="color: #009900;">{</span>
|
|
|
|
<span style="color: #666666; font-style: italic;">// JDBC connection pool size</span>
|
|
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> POOL_SIZE <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
|
|
|
|
<span style="color: #666666; font-style: italic;">// Folder containing models and databases</span>
|
|
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">File</span> baseFolder <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">(</span><span style="color: #0000ff;">"."</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
|
|
|
|
<span style="color: #666666; font-style: italic;">// The subsetter</span>
|
|
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> Subsetter subsetter <span style="color: #339933;">=</span>
|
|
<span style="color: #000000; font-weight: bold;">new</span> Subsetter<span style="color: #009900;">(</span>
|
|
<span style="color: #000000; font-weight: bold;">new</span> BasicDataSource<span style="color: #009900;">(</span>
|
|
<span style="color: #0000ff;">"org.h2.Driver"</span>, <span style="color: #0000ff;">"jdbc:h2:"</span> <span style="color: #339933;">+</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">(</span>baseFolder, <span style="color: #0000ff;">"demo-db/demo-scott"</span><span style="color: #009900;">)</span>.<span style="color: #006633;">getAbsolutePath</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span>, <span style="color: #0000ff;">"sa"</span>, <span style="color: #0000ff;">""</span>,
|
|
POOL_SIZE,
|
|
<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">(</span>baseFolder, <span style="color: #0000ff;">"lib/h2-2.2.224.jar"</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span>,
|
|
<span style="color: #000066; font-weight: bold;">null</span>,
|
|
<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">(</span>baseFolder, <span style="color: #0000ff;">"datamodel/Demo-Scott"</span><span style="color: #009900;">)</span>,
|
|
<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">(</span>baseFolder, <span style="color: #0000ff;">"extractionmodel/Demo-Scott.jm"</span><span style="color: #009900;">)</span>,
|
|
ScriptFormat.<span style="color: #006633;">SQL</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
|
|
|
|
<span style="color: #666666; font-style: italic;">// The importer</span>
|
|
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> Importer importer <span style="color: #339933;">=</span>
|
|
<span style="color: #000000; font-weight: bold;">new</span> Importer<span style="color: #009900;">(</span>
|
|
<span style="color: #000000; font-weight: bold;">new</span> BasicDataSource<span style="color: #009900;">(</span>
|
|
<span style="color: #0000ff;">"org.h2.Driver"</span>, <span style="color: #0000ff;">"jdbc:h2:"</span> <span style="color: #339933;">+</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">(</span>baseFolder, <span style="color: #0000ff;">"demo-db/demo-scott-subset"</span><span style="color: #009900;">)</span>.<span style="color: #006633;">getAbsolutePath</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span>, <span style="color: #0000ff;">"sa"</span>, <span style="color: #0000ff;">""</span>,
|
|
POOL_SIZE,
|
|
<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">(</span>baseFolder, <span style="color: #0000ff;">"lib/h2-2.2.224.jar"</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
|
|
|
|
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
|
|
* Exports data related with employee "SCOTT"
|
|
* and imports it into another database.
|
|
*/</span>
|
|
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">(</span><span style="color: #003399;">String</span><span style="color: #009900;">[</span><span style="color: #009900;">]</span> args<span style="color: #009900;">)</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">SQLException</span>, <span style="color: #003399;">IOException</span> <span style="color: #009900;">{</span>
|
|
<span style="color: #003399;">File</span> exportScriptFile <span style="color: #339933;">=</span> Configuration.<span style="color: #006633;">getInstance</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span>.<span style="color: #006633;">createTempFile</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
|
|
|
|
subsetter.<span style="color: #006633;">setUpsertOnly</span><span style="color: #009900;">(</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// overwrite previous data</span>
|
|
subsetter.<span style="color: #006633;">execute</span><span style="color: #009900;">(</span><span style="color: #0000ff;">"NAME='SCOTT'"</span>, exportScriptFile<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
|
|
|
|
importer.<span style="color: #006633;">execute</span><span style="color: #009900;">(</span>exportScriptFile<span style="color: #009900;">)</span><span style="color: #339933;">;</span>
|
|
|
|
exportScriptFile.<span style="color: #006633;">delete</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>
|
|
<span style="color: #009900;">}</span>
|
|
<span style="color: #009900;">}</span>
|
|
|
|
</pre>
|
|
</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<p><br /></p>
|
|
|
|
<p><br /></p>
|
|
|
|
<p><br />
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td height="12" valign="top" width="14%"><br /></td>
|
|
|
|
<td><br /></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</body>
|
|
</html>
|