Configuration
The configuration file describes how data is partitioned and which driver has to be used.
It has to be in the classpath of the application.
To install and configure Let's Party!:
- Copy the libraries to your classpath
- Change your driver settings
- Set the real connection properties in your configuration file
- Describe your partitioned tables
Copy the libraries to your classpath
Copy Let's Party! library (letsparty.jar) and all its dependencies (commons-beanutils.jar,
commons-collections.jar,
commons-digester.jar,
commons-logging.jar,
dom4j.jar,
jsqlparser.jar) to your classpath.
You can find commons-*.jar at the jakarta site,
dom4j.jar here
and jsqlparser here
(or download all the dependencies
here)
Change your driver settings
Change your driver into net.sf.letsparty.driver.Driver and your connection
string into something like jdbc:letsparty:<path_to_your_config.xml>
Example:
Class.forName("net.sf.letsparty.driver.Driver");
Connection conn = DriverManager.getConnection("jdbc:letsparty:./testfiles/test_config.xml", "username", "password");
Example (tomcat):
<ResourceParams name="jdbc/TestDB">
<parameter>
<name>driverClassName</name>
<value>net.sf.letsparty.driver.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:letsparty:./letsparty.cfg.xml</value>
</parameter>
[...]
</ResourceParams>
The "<path_to_your_config.xml>" can be set to any valid xml resource path
(for example http://mycompany.com/resources/letsparty.cfg.xml)
Set the real connection properties in your configuration file
In your letsparty.cfg.xml, write your connection properties. Example:
<!DOCTYPE letsparty-config PUBLIC "-//LetsParty//LetsParty Configuration DTD 0.1//EN"
"http://letsparty.sourceforge.net/letsparty-configuration-0.1.dtd">
<letsparty-config>
<real-conn>
<url>jdbc:mysql://192.168.0.252:3306/LETSPARTY_TEST?autoReconnect=yes</url>
<driver>com.mysql.jdbc.Driver</driver>
</real-conn>
[...]
</letsparty-config>
Describe your partitioned tables
In your letsparty.cfg.xml, write your partitioned table properties.
Only the partitioned tables of the db have to be configured.
Each table can be partitioned on multiple columns, as described in
partitioning on multiple cols.
Here only an simple example (only one column) is given:
<!DOCTYPE letsparty-config PUBLIC "-//LetsParty//LetsParty Configuration DTD 0.1//EN"
"http://letsparty.sourceforge.net/letsparty-configuration-0.1.dtd">
<letsparty-config>
<real-conn>
<url>jdbc:mysql://192.168.0.252:3306/LETSPARTY_TEST?autoReconnect=yes</url>
<driver>com.mysql.jdbc.Driver</driver>
</real-conn>
<table name="MYTAB_A" separator="_">
<column name="ID1" interval-class="net.sf.letsparty.cfg.IntInterval">
<partition name="1">
<interval from="1" to="2" />
</partition>
<partition name="2">
<interval from="3" to="4" />
</partition>
<partition name="3">
<interval from="5" to="6" />
</partition>
<partition name="4">
<interval from="7" to="8" />
</partition>
</column>
<table name="MYTAB_B" separator="_">
<column name="ID1" interval-class="net.sf.letsparty.cfg.TimestampInterval">
<partition name="1">
<interval from="2003-01-01 00:00:00" to="2003-06-01 00:00:00" />
</partition>
<partition name="2">
<interval from="2003-06-01 00:00:01" to="2004-01-01 00:00:00" />
</partition>
</column>
</table>
</letsparty-config>
Element by element:
<table name="MYTAB_A" separator="_">
It means that the table named MYTAB_A is a partitioned table: it doesn't exist in the
db, only its partitions (MYTAB_A_xxx, such as MY_TAB_4) are stored in the database. The separator
is appended to the table name to create the name of the partitioned table. In case
it is omitted, "_" is the default. Example: if the above declaration was: <table name="MYTAB_A" separator="!">
the name of the partitioned tables would have been MYTAB_A!xxx (example: MY_TAB!4).
Then the column:
<column name="ID1" interval-class="net.sf.letsparty.cfg.IntInterval">
It means that the table is partitioned based on values of the column "ID1". In this example
the type of values is int, hence the class holding intervals values will be
net.sf.letsparty.cfg.IntInterval
. You have to choose from an handler in
net.sf.letsparty.cfg
(Date, Time, Datetime, Long, Double).The
<column>
element has a class
attribute to
override the normal behaviour of the column
(more on this here), in case you need, for example,
to partition data on a monthly basis (and you don't want to specify all dates of all months
from now until the year 2300...)
Then the intervals:
<interval from="7" to="8" />
With this element you describe the contents of your partition, i.e. what values will be in this
partition. You can add more than one <interval>
element.The
from
attribute is the smaller value the partition will have (for this
column) and the to
attribute is the bigger. IMPORTANT: The
from
and to
attributes are INCLUDED, not excluded
in the range of values!