mirror of
https://github.com/Wisser/Jailer.git
synced 2026-05-19 11:28:27 -05:00
316 lines
18 KiB
HTML
316 lines
18 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="installation-2-Dateien/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="0" cellspacing="0">
|
|
<tbody>
|
|
<tr>
|
|
<td colspan="2" class="bannerbackground" height="33" width="100%">
|
|
<table border="0" cellpadding="4" cellspacing="0" width="100%">
|
|
<tbody>
|
|
<tr>
|
|
<td><img src="installation-2-Dateien/logo.png" hspace=
|
|
"10" /></td>
|
|
|
|
<td class="slogan" width="100%">
|
|
Database Subsetting Tool</td>
|
|
|
|
<td style="text-align: right; width: 100%;"><a href=
|
|
"http://sourceforge.net/projects/jailer/"><img src=
|
|
"http://sflogo.sourceforge.net/sflogo.php?group_id=197260&type=1"
|
|
style="border: 0px solid ;" /></a></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td colspan="2" class="nav1background" height="33" 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 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" height="100%" valign="top" width="14%">
|
|
<div align="center">
|
|
<center>
|
|
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
|
<tbody>
|
|
<tr>
|
|
<td width="100%"><br /></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%">
|
|
<small><small> </small></small><br />
|
|
<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</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.csv" 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;'>
|
|
<br />
|
|
<strong><font color=
|
|
'#7F0055'>package</font></strong> net.sf.jailer.api_example;<br />
|
|
|
|
<br />
|
|
<strong><font color=
|
|
'#7F0055'>import</font></strong> java.io.File;<br />
|
|
|
|
<strong><font color=
|
|
'#7F0055'>import</font></strong> java.io.IOException;<br />
|
|
|
|
<strong><font color=
|
|
'#7F0055'>import</font></strong> java.sql.SQLException;<br />
|
|
|
|
<br />
|
|
<strong><font color=
|
|
'#7F0055'>import</font></strong> net.sf.jailer.api.Importer;<br />
|
|
|
|
<strong><font color=
|
|
'#7F0055'>import</font></strong> net.sf.jailer.api.Subsetter;<br />
|
|
|
|
<strong><font color=
|
|
'#7F0055'>import</font></strong> net.sf.jailer.configuration.Configuration;<br />
|
|
|
|
<strong><font color=
|
|
'#7F0055'>import</font></strong> net.sf.jailer.database.BasicDataSource;<br />
|
|
|
|
<strong><font color=
|
|
'#7F0055'>import</font></strong> net.sf.jailer.subsetting.ScriptFormat;<br />
|
|
|
|
<br />
|
|
<font color='#2040A0'>/**<br />
|
|
* Jailer API Example. <br />
|
|
|
|
* <br />
|
|
* Extracts some data from the "demo-scott" database<br />
|
|
|
|
* and imports it into another database "demo-scott-subset".<br />
|
|
|
|
*/</font><br />
|
|
<strong><font color=
|
|
'#7F0055'>public</font></strong> <strong><font color='#7F0055'>class</font></strong> APIExample {<br />
|
|
|
|
<br />
|
|
<font color=
|
|
'#3F7F5F'>// JDBC connection pool size</font><br />
|
|
|
|
<strong><font color=
|
|
'#7F0055'>private</font></strong> <strong><font color='#7F0055'>static</font></strong> <strong><font color='#7F0055'>final</font></strong> <strong><font color='#7F0055'>int</font></strong> POOL_SIZE = 10;<br />
|
|
|
|
<br />
|
|
<font color=
|
|
'#3F7F5F'>// The subsetter</font><br />
|
|
<strong><font color=
|
|
'#7F0055'>private</font></strong> <strong><font color='#7F0055'>static</font></strong> Subsetter subsetter = <br />
|
|
|
|
<strong><font color='#7F0055'>new</font></strong> Subsetter(<br />
|
|
|
|
<strong><font color='#7F0055'>new</font></strong> BasicDataSource(<br />
|
|
|
|
<font color='#2A00FF'>"org.h2.Driver"</font>, <font color='#2A00FF'>"jdbc:h2:demo-scott"</font>, <font color='#2A00FF'>"sa"</font>, <font color='#2A00FF'>""</font>,<br />
|
|
|
|
POOL_SIZE,<br />
|
|
|
|
<strong><font color='#7F0055'>new</font></strong> File(<font color='#2A00FF'>"lib/h2-1.3.160.jar"</font>)),<br />
|
|
|
|
<strong><font color='#7F0055'>null</font></strong>,<br />
|
|
|
|
APIExample.<strong><font color='#7F0055'>class</font></strong>.getResource(<font color='#2A00FF'>"Demo-Scott"</font>),<br />
|
|
|
|
APIExample.<strong><font color='#7F0055'>class</font></strong>.getResource(<font color='#2A00FF'>"Demo-Scott.csv"</font>),<br />
|
|
|
|
ScriptFormat.SQL);<br />
|
|
|
|
<br />
|
|
<font color=
|
|
'#3F7F5F'>// The importer</font><br />
|
|
<strong><font color=
|
|
'#7F0055'>private</font></strong> <strong><font color='#7F0055'>static</font></strong> Importer importer =<br />
|
|
|
|
<strong><font color='#7F0055'>new</font></strong> Importer(<br />
|
|
|
|
<strong><font color='#7F0055'>new</font></strong> BasicDataSource(<br />
|
|
|
|
<font color='#2A00FF'>"org.h2.Driver"</font>, <font color='#2A00FF'>"jdbc:h2:demo-scott-subset"</font>, <font color='#2A00FF'>"sa"</font>, <font color='#2A00FF'>""</font>,<br />
|
|
|
|
10,<br />
|
|
|
|
<strong><font color='#7F0055'>new</font></strong> File(<font color='#2A00FF'>"lib/h2-1.3.160.jar"</font>)));<br />
|
|
|
|
<br />
|
|
<font color=
|
|
'#2040A0'>/**<br />
|
|
* Exports data related with employee "SCOTT"<br />
|
|
|
|
* and imports it into another database.<br />
|
|
|
|
*/</font><br />
|
|
<strong><font color=
|
|
'#7F0055'>public</font></strong> <strong><font color='#7F0055'>static</font></strong> <strong><font color='#7F0055'>void</font></strong> main(String[] args) <strong><font color='#7F0055'>throws</font></strong> SQLException, IOException {<br />
|
|
|
|
File exportScriptFile = Configuration.getInstance().createTempFile();<br />
|
|
|
|
<br />
|
|
|
|
subsetter.setUpsertOnly(<strong><font color='#7F0055'>true</font></strong>); <font color='#3F7F5F'>// overwrite previous data</font><br />
|
|
|
|
subsetter.execute(<font color='#2A00FF'>"NAME='SCOTT'"</font>, exportScriptFile);<br />
|
|
|
|
<br />
|
|
|
|
importer.execute(exportScriptFile);<br />
|
|
|
|
<br />
|
|
|
|
exportScriptFile.delete();<br />
|
|
|
|
}<br />
|
|
<br />
|
|
}<br />
|
|
|
|
<div style=
|
|
'text-align:right;BORDER-TOP: #ccc 1px dashed'>
|
|
<a href=
|
|
"http://www.togotutor.com/code-to-html/java-to-html.php"
|
|
target="_blank">Code Formatted by ToGoTutor</a>
|
|
</div>
|
|
</div>
|
|
</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>
|