Rob Gordon is a seasoned Java developer and a big fan of open source. Oddjob is his own open source project to make job scheduling and task automation in Java much much easier. Rob is based in London. Rob is a DZone MVB and is not an employee of DZone and has posted 17 posts at DZone. You can read more from them at their website. View Full User Profile

An Oddjob Property in Spring

  • submit to reddit

Here’s my previous password passed to Spring example run from Oddjob:

Password Prompt

Run as a GUI, Oddjob provides a simple form for entering properties including a password prompt.

Here’s the Oddjob configuration:

            <input-password prompt="Password" property="jdbc.password" />
        <spring:job beanName="myQuery" xmlns:spring="oddjob:spring">
                <value value="rob/MyQuery.xml" />

The Spring configuration remains unchanged from my previous post, but I include it again here for your convenience:

<beans xmlns=""
  xmlns:xsi="" xmlns:context=""
  <context:property-placeholder location="" />
  <bean id="myQuery" class="rob.MyQuery">
    <property name="dataSource" ref="dataSource" />
  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
    <property name="driverClassName" value="${jdbc.driverClassName}" />
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />

The password prompt sets the property jdbc.password within Oddjob and my new SpringJob automatically makes every property defined in Oddjob available in Spring.

SpringJob can be given the name of any Runnable defined within Spring and it will run it. Any exceptions will be reflected in the state of SpringJob, and this can be used to trigger another job such as an email, or it can be used in a retry timer.

Here it is having run successfully.

Spring Job Completed

The Oddjob configuration can be run directly from the console. The password prompt now changes to use the console:

Spring Job Console View

And that’s a very quick look at an Oddjob property in Spring.

The Oddjob Spring jobs can be found on Sourceforge here. They require Oddjob 1.2 to run, it is still in development but a reasonably stable snapshot can be found here.



Published at DZone with permission of Rob Gordon, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Fahmeed Nawaz replied on Tue, 2012/06/12 - 10:38am

after inserting into collection using collectionname.insert(new BasicDBObject("name","sivu")) in java how to check whether the data inserted or not? I mean do the insert method returns any value which shows the result that data inserted...

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.