Files
Jailer/docs/api.html
2023-07-25 13:36:26 +02:00

232 lines
16 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>&nbsp;</td>
</tr>
</tbody>
</table> </td>
</tr>
</tbody>
</table>
<tr>
<td colspan="2" class="nav1background" width="100%">&nbsp;
<b><font color="#FFFFFF"><a href="home.htm" target="_self" class=
"tlink">&nbsp;Home&nbsp;</a> <a href="quicktour.htm" target=
"_self" class="tlink">&nbsp;Quick Tour&nbsp;</a> <a href=
"exporting-data.htm" target="_self" class="tlink">&nbsp;Tutorial&nbsp;</a>
<a href="data-browsing.html" target="_self" class=
"tlink">&nbsp;Data Browser&nbsp;</a> <a class="tlink" href="videos.html" target="_self">&nbsp;Videos&nbsp;</a> <a href="faq.html" target=
"_self" class="tlink">&nbsp;FAQ&nbsp;</a> <a href="api.html"
target="_self" class="tlinkA">&nbsp;API&nbsp;</a> <a href=
"design.htm" target="_self" class="tlink">&nbsp;Documentation&nbsp;</a>
<a href=
"http://sourceforge.net/forum/?group_id=197260" target="_self" class=
"tlink">&nbsp;Forum&nbsp;</a> <a href=
"http://sourceforge.net/project/showfiles.php?group_id=197260" target=
"_self" class="tlink">&nbsp;Download&nbsp;</a> &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;</font></b></td>
</tr>
<tr>
<td colspan="2" class="spacer" width="100%"></td> </tr><tr><td class="lmenucontainer">&nbsp;</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>&nbsp;</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&nbsp;(<a href="https://mvnrepository.com/artifact/io.github.wisser/jailer-engine">MVN-Repository</a> , also included in jailer-<i>version</i>.zip)</li>
<li>log4J</li>
</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
jailer-engine-<i>version</i>.jar. It extracts some data
from the "demo-scott" database and imports it into another
database "demo-scott-subset".<br />
<ul>
<li>Packages<br />
<img src="apipackages.gif" /><br />
<br />
The data model "Demo-Scott" and the extraction model
"Demo-Scott.jm" are both embedded into the package and
thus accessible as class resources.<br />
<br />
<br /></li>
<li>Source<br />
<div style=
'background:#FFFFFF; font-family: Courier New, Courier; font-size: 10pt; COLOR: #000000; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;'>
<pre style="color:#000000;background:#ffffff;"><span style="color:#800000; font-weight:bold; ">public</span> <span style="color:#800000; font-weight:bold; ">class</span> APIExample <span style="color:#800080; ">{</span>
<span style="color:#696969; ">// JDBC connection pool size</span>
<span style="color:#800000; font-weight:bold; ">private</span> <span style="color:#800000; font-weight:bold; ">static</span> <span style="color:#800000; font-weight:bold; ">final</span> <span style="color:#bb7977; ">int</span> POOL_SIZE <span style="color:#808030; ">=</span> <span style="color:#008c00; ">10</span><span style="color:#800080; ">;</span>
<span style="color:#696969; ">// The subsetter</span>
<span style="color:#800000; font-weight:bold; ">private</span> <span style="color:#800000; font-weight:bold; ">static</span> Subsetter subsetter <span style="color:#808030; ">=</span>
<span style="color:#800000; font-weight:bold; ">new</span> Subsetter<span style="color:#808030; ">(</span>
<span style="color:#800000; font-weight:bold; ">new</span> BasicDataSource<span style="color:#808030; ">(</span>
<span style="color:#0000e6; ">"org.h2.Driver"</span><span style="color:#808030; ">,</span> <span style="color:#0000e6; ">"jdbc:h2:"</span> <span style="color:#808030; ">+</span> <span style="color:#800000; font-weight:bold; ">new</span> <span style="color:#bb7977; font-weight:bold; ">File</span><span style="color:#808030; ">(</span><span style="color:#0000e6; ">"demo-scott"</span><span style="color:#808030; ">)</span><span style="color:#808030; ">.</span>getAbsolutePath<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span><span style="color:#808030; ">,</span> <span style="color:#0000e6; ">"sa"</span><span style="color:#808030; ">,</span> <span style="color:#0000e6; ">""</span><span style="color:#808030; ">,</span>
POOL_SIZE<span style="color:#808030; ">,</span>
<span style="color:#800000; font-weight:bold; ">new</span> <span style="color:#bb7977; font-weight:bold; ">File</span><span style="color:#808030; ">(</span><span style="color:#0000e6; ">"lib/h2-2.1.212.jar"</span><span style="color:#808030; ">)</span><span style="color:#808030; ">)</span><span style="color:#808030; ">,</span>
<span style="color:#800000; font-weight:bold; ">null</span><span style="color:#808030; ">,</span>
APIExample<span style="color:#808030; ">.</span>class<span style="color:#808030; ">.</span>getResource<span style="color:#808030; ">(</span><span style="color:#0000e6; ">"Demo-Scott"</span><span style="color:#808030; ">)</span><span style="color:#808030; ">,</span>
APIExample<span style="color:#808030; ">.</span>class<span style="color:#808030; ">.</span>getResource<span style="color:#808030; ">(</span><span style="color:#0000e6; ">"Demo-Scott.jm"</span><span style="color:#808030; ">)</span><span style="color:#808030; ">,</span>
ScriptFormat<span style="color:#808030; ">.</span>SQL<span style="color:#808030; ">)</span><span style="color:#800080; ">;</span>
<span style="color:#696969; ">// The importer</span>
<span style="color:#800000; font-weight:bold; ">private</span> <span style="color:#800000; font-weight:bold; ">static</span> Importer importer <span style="color:#808030; ">=</span>
<span style="color:#800000; font-weight:bold; ">new</span> Importer<span style="color:#808030; ">(</span>
<span style="color:#800000; font-weight:bold; ">new</span> BasicDataSource<span style="color:#808030; ">(</span>
<span style="color:#0000e6; ">"org.h2.Driver"</span><span style="color:#808030; ">,</span> <span style="color:#0000e6; ">"jdbc:h2:"</span> <span style="color:#808030; ">+</span> <span style="color:#800000; font-weight:bold; ">new</span> <span style="color:#bb7977; font-weight:bold; ">File</span><span style="color:#808030; ">(</span><span style="color:#0000e6; ">"demo-scott-subset"</span><span style="color:#808030; ">)</span><span style="color:#808030; ">.</span>getAbsolutePath<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span><span style="color:#808030; ">,</span> <span style="color:#0000e6; ">"sa"</span><span style="color:#808030; ">,</span> <span style="color:#0000e6; ">""</span><span style="color:#808030; ">,</span>
<span style="color:#008c00; ">10</span><span style="color:#808030; ">,</span>
<span style="color:#800000; font-weight:bold; ">new</span> <span style="color:#bb7977; font-weight:bold; ">File</span><span style="color:#808030; ">(</span><span style="color:#0000e6; ">"lib/h2-2.1.212.jar"</span><span style="color:#808030; ">)</span><span style="color:#808030; ">)</span><span style="color:#808030; ">)</span><span style="color:#800080; ">;</span>
<span style="color:#3f5fbf; ">/**</span>
<span style="color:#3f5fbf; "> </span><span style="color:#7f9fbf; font-weight:bold; ">*</span><span style="color:#3f5fbf; "> Exports data related with employee "SCOTT"</span>
<span style="color:#3f5fbf; "> </span><span style="color:#7f9fbf; font-weight:bold; ">*</span><span style="color:#3f5fbf; "> and imports it into another database.</span>
<span style="color:#3f5fbf; "> */</span>
<span style="color:#800000; font-weight:bold; ">public</span> <span style="color:#800000; font-weight:bold; ">static</span> <span style="color:#bb7977; ">void</span> main<span style="color:#808030; ">(</span><span style="color:#bb7977; font-weight:bold; ">String</span><span style="color:#808030; ">[</span><span style="color:#808030; ">]</span> args<span style="color:#808030; ">)</span> <span style="color:#800000; font-weight:bold; ">throws</span> <span style="color:#bb7977; font-weight:bold; ">SQLException</span><span style="color:#808030; ">,</span> <span style="color:#bb7977; font-weight:bold; ">IOException</span> <span style="color:#800080; ">{</span>
<span style="color:#bb7977; font-weight:bold; ">File</span> exportScriptFile <span style="color:#808030; ">=</span> Configuration<span style="color:#808030; ">.</span>getInstance<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span><span style="color:#808030; ">.</span>createTempFile<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span><span style="color:#800080; ">;</span>
subsetter<span style="color:#808030; ">.</span>setUpsertOnly<span style="color:#808030; ">(</span><span style="color:#800000; font-weight:bold; ">true</span><span style="color:#808030; ">)</span><span style="color:#800080; ">;</span> <span style="color:#696969; ">// overwrite previous data</span>
subsetter<span style="color:#808030; ">.</span>execute<span style="color:#808030; ">(</span><span style="color:#0000e6; ">"NAME='SCOTT'"</span><span style="color:#808030; ">,</span> exportScriptFile<span style="color:#808030; ">)</span><span style="color:#800080; ">;</span>
importer<span style="color:#808030; ">.</span>execute<span style="color:#808030; ">(</span>exportScriptFile<span style="color:#808030; ">)</span><span style="color:#800080; ">;</span>
exportScriptFile<span style="color:#808030; ">.</span>delete<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span><span style="color:#800080; ">;</span>
<span style="color:#800080; ">}</span>
<span style="color:#800080; ">}</span>
</pre>
<br />
<div style=
'text-align:right;BORDER-TOP: #ccc 1px dashed'>
</div>
</div>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
</div>
<p><br /></p>
<p><br /></p>
<p><br />
&nbsp;</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>