• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using init-param to set a value in a table

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a table for online job applications. This table has a 'End_date_time' column which is a VARCHAR, its the date time ceiling for a job offer.

I have a JobBean and a JobDAO. In the JobDAO i have a method selectJobBean(long jobId), jobId being the primary key for this table. I also have a static method initializeBean(JobBean jBean) where I initialize the status of a job bean and set the status to 'OPEN' or 'CLOSED' based on the current date-time being greater than or less than the 'End_date_time' value respectively.

And I call this initializeBean() from the parameterized constructor of JobBean class, JobBean(long jobId).

This works fine. But I am not too happy with this approach. I could use a database trigger to set the status of a job.

But is there a way to do this using an init-param making minimal changes? I am controlling the whole process using a JobControllerServlet.


[ October 12, 2006: Message edited by: vishwanath nadimpally ]
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Few comments (haven't read through the code completely)...

Why are you saving the date data using Strings? JDBC can handle dates using setDate().

Don't use triggers, especially not for what you're describing (business logic). You could say you don't need the status field (since its values is predetermined by 2 other fields), but its likely you will have other values such as "open" "close" "on-hold" "paused" etc, so having the field is useful.
 
vishwanath nadimpally
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Scott Selikoff:
Few comments (haven't read through the code completely)...

Why are you saving the date data using Strings? JDBC can handle dates using setDate().

Don't use triggers, especially not for what you're describing (business logic). You could say you don't need the status field (since its values is predetermined by 2 other fields), but its likely you will have other values such as "open" "close" "on-hold" "paused" etc, so having the field is useful.



The javascript calendar I am using to get the date returns a date time in this format "MM/dd/yyyy hh:mm:ss aaa" andI found I never knew about the setDate(), Thanks for that.

Also, the same job can be "opened" at a later date just by changing the date from an 'admin screen', So the status column is required.
 
Scott Selikoff
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe I'm missing something (probably) but how edoes this relate to init-params, or better question, how is this a servlet issue?

BTW- I don't see the problem with explicitly setting the status every time. You could just write a static helper method that determines the status based on the input. It would still be better to put this in java code rather than a db trigger.
 
vishwanath nadimpally
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont think you missed anything. I got confused somehow that I can use the 'End_date_time' as an init-param and set the status in my servlet (Using a static helper ofcourse.) but then I would need a jobId (primary key) of the row I want to update.

So I am going to stick with what I have. Thanks for suggestions.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic