public class HsqldbJob
extends java.lang.Object
<oddjob id="this"> <job> <sequential id="top" name="Run in Sequence"> <jobs> <properties> <values> <value key="work.dir" value="./work/hsql-example"/> </values> </properties> <hsql:hsqldb name="Hsqldb Server" xmlns:hsql="http://rgordon.co.uk/oddjob/hsql"> <database> <value key="mydb" value="${work.dir}/mydb"/> </database> <properties> <properties> <values> <value key="server.port" value="11001"/> <value key="server.silent" value="false"/> </values> </properties> </properties> </hsql:hsqldb> <variables id="vars"> <connection> <hsql:connection url="jdbc:hsqldb:hsql://localhost:11001/mydb" username="sa" xmlns:hsql="http://rgordon.co.uk/oddjob/hsql"/> </connection> </variables> <folder name="Setup Sql"> <jobs> <sequential id="setup" name="All"> <jobs> <sql name="Create table"> <connection> <value value="${vars.connection}"/> </connection> <input> <buffer>create table greetings ( style varchar(20), greeting varchar(30),constraint greetings_pk primary key (style))</buffer> </input> </sql> <sql name="Insert1"> <connection> <value value="${vars.connection}"/> </connection> <input> <buffer>insert into greetings values ('nice', 'hello')</buffer> </input> </sql> <sql name="Insert1"> <connection> <value value="${vars.connection}"/> </connection> <input> <buffer>insert into greetings values ('grumpy', 'bah humbug')</buffer> </input> </sql> </jobs> </sequential> </jobs> </folder> <folder name="Query Sql"> <jobs> <sequential id="single-query" name="All"> <jobs> <sql id="query" name="Query"> <connection> <value value="${vars.connection}"/> </connection> <input> <buffer>select greeting from greetings where style='nice'</buffer> </input> <results> <sql-results-bean/> </results> </sql> <echo id="result">${query.results.row.GREETING}</echo> <echo id="resultindexed">${query.results.rows[0].GREETING}</echo> </jobs> </sequential> </jobs> </folder> <folder name="Query All"> <jobs> <sequential id="all-query" name="All"> <jobs> <sql id="queryall" name="Query"> <connection> <value value="${vars.connection}"/> </connection> <input> <buffer>select style, greeting from greetings</buffer> </input> <results> <sql-results-bean/> </results> </sql> <foreach id="for"> <values> <value value="${queryall.results.rows}"/> </values> <configuration> <inline> <foreach id="each"> <job> <echo name="Echo Row ${each.index}">${each.current.STYLE} is ${each.current.GREETING}</echo> </job> </foreach> </inline> </configuration> </foreach> </jobs> </sequential> </jobs> </folder> <folder name="Cleanup Sql"> <jobs> <sql id="clean-up" name="Sql Job"> <connection> <value value="${vars.connection}"/> </connection> <input> <buffer>drop table greetings</buffer> </input> </sql> </jobs> </folder> </jobs> </sequential> </job> </oddjob>
SQLPersisterService
.
<oddjob> <job> <sequential name="Sql Persister Example"> <jobs> <hsql:hsqldb name="Database Server" xmlns:hsql="http://rgordon.co.uk/oddjob/hsql"> <database> <value key="ojdb" value="${work.dir}/ojdb"/> </database> <properties> <properties> <values> <value key="server.port" value="11002"/> <value key="server.silent" value="false"/> </values> </properties> </properties> </hsql:hsqldb> <variables id="vars"> <persisterConnection> <hsql:connection url="jdbc:hsqldb:hsql://localhost:11002/ojdb" username="sa" xmlns:hsql="http://rgordon.co.uk/oddjob/hsql"/> </persisterConnection> </variables> <sql name="Create table"> <connection> <value value="${vars.persisterConnection}"/> </connection> <input> <buffer>CREATE TABLE oddjob( path VARCHAR(32), id VARCHAR(32), job BLOB, CONSTRAINT oddjob_pk PRIMARY KEY (path, id))</buffer> </input> </sql> <sql-persister-service id="persister-service"> <connection> <value value="${vars.persisterConnection}"/> </connection> </sql-persister-service> <oddjob id="database-persist-example" name="A Database Persisted Oddjob"> <configuration> <arooa:configuration resource="org/oddjob/hsql/OddjobToPersist.xml" xmlns:arooa="http://rgordon.co.uk/oddjob/arooa"/> </configuration> <persister> <value value="${persister-service.persister(example)}"/> </persister> </oddjob> <folder name="Cleanup Sql"> <jobs> <sql id="clean-up" name="Sql Job"> <connection> <value value="${vars.persisterConnection}"/> </connection> <input> <buffer>drop table oddjob</buffer> </input> </sql> </jobs> </folder> </jobs> </sequential> </job> </oddjob>
Constructor and Description |
---|
HsqldbJob() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getDatabase(java.lang.String name)
Get the database path for a give name.
|
java.lang.String |
getName()
Get the name.
|
java.util.Properties |
getProperties()
Getter for properties.
|
java.lang.Integer |
getServerState() |
void |
setDatabase(java.lang.String name,
java.lang.String path)
Set the database name.
|
void |
setName(java.lang.String name)
Set the name.
|
void |
setProperties(java.util.Properties properties)
Setter for server properties.
|
void |
start()
Start the server.
|
void |
stop()
Stop the server.
|
java.lang.String |
toString() |
public java.lang.String getName()
public void setName(java.lang.String name)
name
- The name.public java.lang.String getDatabase(java.lang.String name)
name
- The database path.public void setDatabase(java.lang.String name, java.lang.String path)
name
- The database name.public void setProperties(java.util.Properties properties)
properties
- The property name.value
- The property value.public java.util.Properties getProperties()
name
- The property name.public void start() throws java.io.IOException, org.hsqldb.server.ServerAcl.AclFormatException
org.hsqldb.server.ServerAcl.AclFormatException
java.io.IOException
public void stop()
public java.lang.Integer getServerState()
Property: serverState
Description: The current state of this server in numerically coded form.
Typically, this will be one of:
Required: Read Only.
public java.lang.String toString()
toString
in class java.lang.Object