Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

logic to display quotes,changing with systemdate  RSS feed

 
usha mocherla
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to know the logic for displaying the quotes in the footer of pages of own-created-website.The quotes should change daily.Also there is facility for adding new quotes.So everytime time the there is change in database also.And whenever we are retrieving the quotes all should be displayed atleast once.
Again i repeat that quotes should change with the system date.
Please anybody can help me.
Thanks
regards
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
date is somewhat infinite thing. you wouldn't get that date again once you got that before. it means you need some cycle kind of mechanism for your quote stuff, right?

why not just make a logical circular queue in QUOTES table.
[ October 26, 2004: Message edited by: adeel ansari ]
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i reached somewhere here, see.

we have a table,
QUOTES (ID, QUOTE)

for example the ids are incremental i.e. 1, 2, 3, 4 .. . . 100

take two attributes. you can place it in some file, in your db, or in application context. i.e. date, and previousId. date would be the system date, means it get changed everyday, and previousId intially has the value of 1, and then we increment it by one each day till MAX_ID in the DB. after gettin the max set it again to MIN_ID.

now increment your previousId.
fetch the record by matching id with previousId.
and show the quote.

hope you get this. other better options are welcome, because i am a bit busy right now. dont know the idea is good or poor.
 
usha mocherla
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i got the solution.i m using thread concept where i m making it sleep for 24 hrs after executing one quote.
the server is starting once and so the thread is initiallised once.the quote is displayed and remains in the application throughout the day.
because the thread goes to sleep for 24 hrs.
meanwhile if i 've to restart the server the thread is not allowing me to do so.again and again i 've to restart the system.
is there any way to to stop the tomcat,without shutting the system.
thanx
regards
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've used Quartz to accomplish something similiar in a project I'm working on. If you use Quartz's JDBCJobStore, any jobs you add to the scheduler can be persisted to a database, so jobs will be persistent across server shutdown.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!