Class SQLPersisterService

java.lang.Object
org.oddjob.sql.SQLPersisterService

public class SQLPersisterService extends Object
Author:
Rob Gordon.

Description

Persists job state to a database. The database must have a table which can be created with the following sql.

 CREATE TABLE oddjob(
   path VARCHAR(128), 
   id VARCHAR(32), 
   job BLOB, 
  CONSTRAINT oddjob_pk PRIMARY KEY (path, id))
 

Example

Using a SQL Persister.
<oddjob id="this">

    <job>

        <sequential>

            <jobs>

                <sql-persister-service id="sql-persister">

                    <connection>

                        <connection driver="org.hsqldb.jdbcDriver" url="jdbc:hsqldb:mem:test" username="sa"/>

                    </connection>

                </sql-persister-service>

                <oddjob id="oj" file="${this.dir}/SQLPersisterInner.xml">

                    <persister>

                        <value value="${sql-persister.persister(test)}"/>

                    </persister>

                </oddjob>

                <stop job="${sql-persister}"/>

            </jobs>

        </sequential>

    </job>

</oddjob>
Note that because this is a service, it must be stopped once the inner Oddjob has completed it's work. In an Oddjob that was running continually this would not be necessary.